private ExecutorService initializeServerConnectionThreadPool() throws IOException {
String threadName = "ServerConnection on port " + this.localPort + " Thread ";
ThreadInitializer threadInitializer = thread -> getStats().incConnectionThreadsCreated();
CommandWrapper commandWrapper = command -> {
try {
command.run();
} catch (CancelException e) {
} finally {
ConnectionTable.releaseThreadsSockets();
}
};
try {
if (isSelector()) {
return LoggingExecutors.newThreadPoolWithUnlimitedFeed(threadName, threadInitializer,
commandWrapper, this.maxThreads,
getStats().getCnxPoolHelper(), Integer.MAX_VALUE, getThreadMonitorObj());
} else {
return LoggingExecutors.newThreadPoolWithSynchronousFeed(threadName, threadInitializer,
commandWrapper,
MINIMUM_MAX_CONNECTIONS, this.maxConnections, 0L);
}
} catch (IllegalArgumentException poolInitException) {
this.stats.close();
this.serverSock.close();
throw poolInitException;
}
}