/** * Creates a new instance of {@link AbstractCoapApplication}. * * @param applicationName the given name of this application (for logging only) */ protected AbstractCoapApplication(String applicationName) { this.applicationName = applicationName; ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat(applicationName + " I/O Worker #%d").build(); ThreadRenamingRunnable.setThreadNameDeterminer(new ThreadNameDeterminer() { @Override public String determineThreadName(String currentThreadName, String proposedThreadName) throws Exception { return null; } }); // determine number of I/O threads and create thread pool executor of that size int ioThreads = Math.max(Runtime.getRuntime().availableProcessors() * 2, 4); this.executor = new ScheduledThreadPoolExecutor(ioThreads, threadFactory); // this.executor = new SynchronizedExecutor(ioThreads, threadFactory); }