Java Code Examples for java.util.concurrent.Executors.unconfigurableExecutorService()

The following are Jave code examples for showing how to use unconfigurableExecutorService() of the java.util.concurrent.Executors class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: lams   File: ThreadPoolExecutorFactoryBean.java   View Source Code Vote up 6 votes
@Override
protected ExecutorService initializeExecutor(
		ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {

	BlockingQueue<Runnable> queue = createQueue(this.queueCapacity);
	ThreadPoolExecutor executor  = createExecutor(this.corePoolSize, this.maxPoolSize,
			this.keepAliveSeconds, queue, threadFactory, rejectedExecutionHandler);
	if (this.allowCoreThreadTimeOut) {
		executor.allowCoreThreadTimeOut(true);
	}

	// Wrap executor with an unconfigurable decorator.
	this.exposedExecutor = (this.exposeUnconfigurableExecutor ?
			Executors.unconfigurableExecutorService(executor) : executor);

	return executor;
}
 
Example 2
Project: guava-mock   File: MoreExecutors.java   View Source Code Vote up 5 votes
final ExecutorService getExitingExecutorService(
    ThreadPoolExecutor executor, long terminationTimeout, TimeUnit timeUnit) {
  useDaemonThreadFactory(executor);
  ExecutorService service = Executors.unconfigurableExecutorService(executor);
  addDelayedShutdownHook(service, terminationTimeout, timeUnit);
  return service;
}
 
Example 3
Project: openjdk-jdk10   File: ExecutorsTest.java   View Source Code Vote up 5 votes
/**
 * unconfigurableExecutorService(null) throws NPE
 */
public void testUnconfigurableExecutorServiceNPE() {
    try {
        ExecutorService e = Executors.unconfigurableExecutorService(null);
        shouldThrow();
    } catch (NullPointerException success) {}
}
 
Example 4
Project: googles-monorepo-demo   File: MoreExecutors.java   View Source Code Vote up 5 votes
final ExecutorService getExitingExecutorService(
    ThreadPoolExecutor executor, long terminationTimeout, TimeUnit timeUnit) {
  useDaemonThreadFactory(executor);
  ExecutorService service = Executors.unconfigurableExecutorService(executor);
  addDelayedShutdownHook(service, terminationTimeout, timeUnit);
  return service;
}
 
Example 5
Project: openjdk-jdk10   File: ExecutorsTest.java   View Source Code Vote up 4 votes
/**
 * An unconfigurable newFixedThreadPool can execute runnables
 */
public void testUnconfigurableExecutorService() {
    final ExecutorService e = Executors.unconfigurableExecutorService(Executors.newFixedThreadPool(2));
    try (PoolCleaner cleaner = cleaner(e)) {
        e.execute(new NoOpRunnable());
        e.execute(new NoOpRunnable());
        e.execute(new NoOpRunnable());
    }
}
 
Example 6
Project: hashsdn-controller   File: FixedThreadPoolWrapper.java   View Source Code Vote up 4 votes
@Override
public ExecutorService getExecutor() {
    return Executors.unconfigurableExecutorService(executor);
}
 
Example 7
Project: hashsdn-controller   File: FlexibleThreadPoolWrapper.java   View Source Code Vote up 4 votes
@Override
public ExecutorService getExecutor() {
    return Executors.unconfigurableExecutorService(executor);
}