this.setServerExecutors(new ThreadPoolExecutor(this.getServerPoolSize(),
this.getServerPoolSize(),
60,
TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(this.getExecutorQueueSize()),
new NamedThreadFactory("TCPServer-Listener"),
new ThreadPoolExecutor.CallerRunsPolicy()));
}
else { // default behavior of creating and using a cached thread pool
this.setServerExecutors(Executors.newCachedThreadPool(new NamedThreadFactory("TCPServer-Listener")));
}
}
if (this.getWorkerExecutors() == null) { // no executors have been set for workers
if (this.getWorkerPoolSize() != TCPNettyServer.INVALID_POOL_SIZE) { // thread pool size has not been set.
this.setWorkerExecutors(new ThreadPoolExecutor(this.getWorkerPoolSize(),
this.getWorkerPoolSize(),
60,
TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(this.getExecutorQueueSize()),
new NamedThreadFactory("TCPServer-Worker"),
new ThreadPoolExecutor.CallerRunsPolicy()));
} else { // default behavior of creating and using a cached thread pool
this.setWorkerExecutors(Executors.newCachedThreadPool(new NamedThreadFactory("TCPServer-Worker")));
}
}
super.afterPropertiesSet();
}