List of usage examples for java.util.concurrent Executors newCachedThreadPool
public static ExecutorService newCachedThreadPool(ThreadFactory threadFactory)
From source file:Main.java
public static void main(String[] args) { final ThreadGroup threadGroup = new ThreadGroup("workers"); ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() { public Thread newThread(Runnable r) { return new Thread(threadGroup, r); }/*from www .j a v a2 s . c om*/ }); System.out.println(threadGroup.activeCount()); }
From source file:Main.java
public static ExecutorService createEventsUnorderedDeliveryExecutor() { return Executors.newCachedThreadPool(new ThreadFactory() { private AtomicInteger cnt = new AtomicInteger(0); @Override/* w w w .j a v a2 s. c o m*/ public Thread newThread(Runnable r) { Thread t = new Thread(r, "Unordered Events Thread-" + cnt.incrementAndGet()); t.setDaemon(true); // XXX perhaps set uncaught exception handler here according to resilience strategy return t; } }); }
From source file:Main.java
/** * Wrapper over newCachedThreadPool. Thread names are formatted as prefix-ID, where ID is a * unique, sequentially assigned integer. *//*from w ww . ja v a 2 s . co m*/ public ThreadPoolExecutor newDaemonCachedThreadPool(String prefix) { ThreadFactory threadFactory = namedThreadFactory(prefix); return (ThreadPoolExecutor) Executors.newCachedThreadPool(threadFactory); }
From source file:code.google.nfs.rpc.mina.server.MinaServer.java
public MinaServer() { acceptor = new SocketAcceptor(Runtime.getRuntime().availableProcessors() + 1, Executors.newCachedThreadPool(new NamedThreadFactory(ACCEPTOR_THREADNAME))); acceptor.getDefaultConfig().setThreadModel(ThreadModel.MANUAL); acceptor.getDefaultConfig().getFilterChain().addLast("objectserialize", new MinaProtocolCodecFilter()); }
From source file:com.google.zxing.client.android.result.supplement.SupplementalInfoRetriever.java
private static synchronized ExecutorService getExecutorService() { if (executorInstance == null) { executorInstance = Executors.newCachedThreadPool(new ThreadFactory() { public Thread newThread(Runnable r) { Thread t = new Thread(r); t.setDaemon(true);/*from w w w .j ava2s . c o m*/ return t; } }); } return executorInstance; }
From source file:pzalejko.iot.hardware.home.core.service.DefaultTaskExecutor.java
public DefaultTaskExecutor() { this(Executors.newScheduledThreadPool(THREAD_POOL_SIZE, new InternalThreadFactory()), Executors.newCachedThreadPool(new InternalThreadFactory())); }
From source file:code.google.nfs.rpc.netty.server.NettyServer.java
public NettyServer() { ThreadFactory serverBossTF = new NamedThreadFactory("NETTYSERVER-BOSS-"); ThreadFactory serverWorkerTF = new NamedThreadFactory("NETTYSERVER-WORKER-"); bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory( Executors.newCachedThreadPool(serverBossTF), Executors.newCachedThreadPool(serverWorkerTF))); bootstrap.setOption("tcpNoDelay", Boolean.parseBoolean(System.getProperty("nfs.rpc.tcp.nodelay", "true"))); bootstrap.setOption("reuseAddress", Boolean.parseBoolean(System.getProperty("nfs.rpc.tcp.reuseaddress", "true"))); }
From source file:code.google.nfs.rpc.mina.client.MinaClientFactory.java
private MinaClientFactory() { // only one ioConnector,avoid create too many io processor thread ioConnector = new SocketConnector(processorCount, Executors.newCachedThreadPool(CONNECTOR_TFACTORY)); }
From source file:com.hellblazer.jackal.configuration.ThreadConfig.java
@Bean(name = "agentDispatchers") @Lazy//from www . j a v a 2s . com @Autowired public ExecutorService agentDispatchers(Identity partitionIdentity) { final int id = partitionIdentity.id; return Executors.newCachedThreadPool(new ThreadFactory() { int count = 0; @Override public Thread newThread(Runnable target) { Thread t = new Thread(target, String.format("Agent Dispatcher[%s] for node[%s]", count++, id)); t.setDaemon(true); t.setUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { log.error(String.format("Exception on %s", t), e); } }); return t; } }); }
From source file:org.eclipse.rdf4j.http.client.SharedHttpClientSessionManager.java
public SharedHttpClientSessionManager() { this.executor = Executors .newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("rdf4j-sesameclientimpl-%d").build()); }