Returns factory which transforms ExecutorService to ConcurrentService. On starting it doing nothing, on stopping it shuts down ExecutorService.
976657
public static ServiceAdapter<ExecutorService> forExecutorService() {
		return new SimpleServiceAdapter<ExecutorService>(false, true) {
			@Override
			protected void start(ExecutorService instance) {
			}

			@Override
			protected void stop(ExecutorService instance) throws Exception {
				List<Runnable> runnables = instance.shutdownNow();
				if (!runnables.isEmpty()) {
					logger.warn("Cancelled tasks: " + runnables);
				}
				if (!instance.isTerminated()) {
					logger.warn("Awaiting termination of " + instance + " ...");
					instance.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
				}
			}
		};
	}
923168
@Override
    public ServiceCacheBuilder<T> threadFactory(ThreadFactory threadFactory)
    {
        this.threadFactory = threadFactory;
        this.executorService = null;
        return this;
    }
1261366
private FutureRequestExecutionService buildRequestExecutorService(final CloseableHttpClient httpClient) {
        if (this.executorService == null) {
            this.executorService = new ThreadPoolExecutor(this.threadsNumber, this.threadsNumber, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(this.queueSize));
        }
        return new FutureRequestExecutionService(httpClient, this.executorService);
    }
1342298
public static boolean shutdownExecutorService(ExecutorService executorService) {
    if (executorService == null) {
      return false;
    }
    //If it hasn't already shutdown, do shutdown.
    if (!executorService.isShutdown()) {
      executorService.shutdown();
    }

    try {
      //Wait for clean termination
      if (executorService.awaitTermination(5, TimeUnit.SECONDS)) {
        return true;
      }

      //If not already terminated (via shutdownNow) do shutdownNow.
      if (!executorService.isTerminated()) {
        executorService.shutdownNow();
      }

      if (executorService.awaitTermination(5, TimeUnit.SECONDS)) {
        return true;
      }

      if (LOGGER.isDebugEnabled()) {
        List<Runnable> tasks = executorService.shutdownNow();
        if (!tasks.isEmpty()) {
          LOGGER.debug("ExecutorService was not cleanly shutdown, after waiting for 10 seconds. Number of remaining tasks:" + tasks.size());
        }
      }
    } catch (InterruptedException e) {
      executorService.shutdownNow();
      //Preserve interrupted status
      Thread.currentThread().interrupt();
    }
    return false;
  }
987782
public AbstractCounterFactory init() {
        int numProcessors = Runtime.getRuntime().availableProcessors();
        counterCache = CacheBuilder.newBuilder().concurrencyLevel(Math.max(numProcessors, 8))
                .expireAfterAccess(3600, TimeUnit.SECONDS)
                .removalListener(new RemovalListener<String, ICounter>() {
                    @Override
                    public void onRemoval(RemovalNotification<String, ICounter> notification) {
                        ICounter counter = notification.getValue();
                        destroyCounter(counter);
                    }
                }).build(new CacheLoader<String, ICounter>() {
                    @Override
                    public ICounter load(String key) throws Exception {
                        return createCounter(key);
                    }
                });
        return this;
    }
758872
public static SimpleReact parallelCommonBuilder() {
        return SimpleReact.builder()
                          .executor(ThreadPools.getStandard())
                          .async(true)
                          .build();

    }
472462
public com.bazaarvoice.ostrich.AsyncServicePool<S> buildAsync() {
        ServicePool<S> pool = buildInternal();

        boolean shutdownAsyncExecutorOnClose = (_asyncExecutor == null);
        if (_asyncExecutor == null) {
            ThreadFactory threadFactory = new ThreadFactoryBuilder()
                    .setNameFormat(_serviceName + "-AsyncExecutorThread-%d")
                    .setDaemon(true)
                    .build();
            _asyncExecutor = Executors.newCachedThreadPool(threadFactory);
        }

        return new AsyncServicePool<>(Ticker.systemTicker(), pool, true, _asyncExecutor,
                shutdownAsyncExecutorOnClose, _metrics);
    }
455904
public static ExecutorService startWithSingleExecutorService(String message,
            Runnable runnable) {
        return startWithExecutorService(newSingleThreadPool(), message,
                runnable);
    }
496505
static synchronized ExecutorService getExecutorService() {
        if (executorService == null) {
            executorService = Executors.newCachedThreadPool(new NamingThreadFactory(new DaemonThreadFactory(), "org.jenkinsci.plugins.pipeline.maven.fix.jenkins49337.GeneralNonBlockingStepExecution"));
        }
        return executorService;
    }
622402
def stopService(self):
        
        self._service.factory.stopTrying()
        yield self._service.factory.stopFactory()
        yield service.MultiService.stopService(self)
1140528
private static synchronized ExecutorService initAsyncExecutorService() {
		if (ASYNC_EXECUTOR_SERVICE == null) {
			ASYNC_EXECUTOR_SERVICE = java.util.concurrent.Executors.newSingleThreadExecutor(
				new ThreadFactory() {
					public Thread newThread(Runnable r) {
						Thread thread = new Thread(r, "javasimon-async");
						thread.setDaemon(true);
						return thread;
					}
				});
		}
		return ASYNC_EXECUTOR_SERVICE;
	}
1267351
private static ThreadFactory createThreadFactory(ThreadFactory threadFactory, String threadNamePrefix,
			Boolean daemon) {
		if (threadFactory != null) {
			return threadFactory;
		}

		if (threadNamePrefix != null) {
			if (daemon != null) {
				return ThreadPoolUtil.buildThreadFactory(threadNamePrefix, daemon);
			} else {
				return ThreadPoolUtil.buildThreadFactory(threadNamePrefix);
			}
		}

		return Executors.defaultThreadFactory();
	}
878042
def getFactory(self):
        
        factory = ServerFactory()
        def protocol():
            proto = CredReceiver()
            proto.portal = Portal(
                self.loginSystem,
                [self.loginSystem,
                 OneTimePadChecker(self._oneTimePads)])
            return proto
        factory.protocol = protocol
        return factory
1119526
private ExecutorService _createExecutorService() {
        int producerConnections = Math.max(Integer.valueOf(
            _configuration.getValue(Property.KAFKA_PRODUCER_CONNECTIONS.getName(), Property.KAFKA_PRODUCER_CONNECTIONS.getDefaultValue())), 10);

        return Executors.newFixedThreadPool(producerConnections, new ThreadFactory() {

                AtomicInteger id = new AtomicInteger(0);

                @Override
                public Thread newThread(Runnable r) {
                    return new Thread(r, MessageFormat.format("kafka-producer-worker-{0}", id.getAndIncrement()));
                }
            });
    }
1066990
public static Executor createExecutor(int threadPoolSize, int threadPriority,
			QueueProcessingType tasksProcessingType) {
		boolean lifo = tasksProcessingType == QueueProcessingType.LIFO;
		BlockingQueue<Runnable> taskQueue =
				lifo ? new LIFOLinkedBlockingDeque<Runnable>() : new LinkedBlockingQueue<Runnable>();
		return new ThreadPoolExecutor(threadPoolSize, threadPoolSize, 0L, TimeUnit.MILLISECONDS, taskQueue,
				createThreadFactory(threadPriority, "uil-pool-"));
	}
1060109
public static DSFactory get() {
		if (null == factory) {
			synchronized (lock) {
				if (null == factory) {
					factory = DSFactory.create(null);
				}
			}
		}
		return factory;
	}
1046264
public static NiftyProcessorFactory factoryFromTProcessorFactory(final TProcessorFactory standardThriftProcessorFactory)
    {
        checkProcessMethodSignature();

        return new NiftyProcessorFactory()
        {
            @Override
            public NiftyProcessor getProcessor(TTransport transport)
            {
                return processorFromTProcessor(standardThriftProcessorFactory.getProcessor
                        (transport));
            }
        };
    }