Source:
<code>protected XnioWorker(final Builder builder) { this.xnio = builder.xnio; this.terminationTask = builder.terminationTask; final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(CREATE_WORKER_PERMISSION); } String workerName = builder.getWorkerName(); if (workerName == null) { workerName = "XNIO-" + seq.getAndIncrement(); } name = workerName; final boolean markThreadAsDaemon = builder.isDaemon(); bindAddressTable = builder.getBindAddressConfigurations(); final Runnable terminationTask = new Runnable() { public void run() { taskPoolTerminated(); } }; final ExecutorService executorService = builder.getExternalExecutorService(); if (executorService != null) { if (executorService instanceof EnhancedQueueExecutor) { taskPool = new ExternalTaskPool( new EnhancedQueueExecutorTaskPool((EnhancedQueueExecutor) executorService)); } else { taskPool = new ExternalTaskPool(new ExecutorServiceTaskPool(executorService)); <START> } <END> } else if (EnhancedQueueExecutor.DISABLE_HINT) { final int poolSize = max(builder.getMaxWorkerPoolSize(), builder.getCoreWorkerPoolSize()); taskPool = new ThreadPoolExecutorTaskPool( poolSize, poolSize, builder.getWorkerKeepAlive(), TimeUnit.MILLISECONDS, new LinkedBlockingDeque<>(), new WorkerThreadFactory(builder.getThreadGroup(), builder.getWorkerStackSize(), markThreadAsDaemon), terminationTask); } else { taskPool = new EnhancedQueueExecutorTaskPool(new EnhancedQueueExecutor.Builder() .setCorePoolSize(builder.getCoreWorkerPoolSize()) .setMaximumPoolSize(builder.getMaxWorkerPoolSize()) .setKeepAliveTime(builder.getWorkerKeepAlive(), TimeUnit.MILLISECONDS) .setThreadFactory(new WorkerThreadFactory(builder.getThreadGroup(), builder.getWorkerStackSize(), markThreadAsDaemon)) .setTerminationTask(terminationTask) .setRegisterMBean(true) .setMBeanName(workerName) .build() ); } }</code><technical_language>If this far, feels adapting ThreadPoolExecutors well. that, a matter of expediency, TPE TaskPool implements interface subclasses TPE, reused..</technical_language>

Target:
protected XnioWorker(final Builder builder) { this.xnio = builder.xnio; this.terminationTask = builder.terminationTask; final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(CREATE_WORKER_PERMISSION); } String workerName = builder.getWorkerName(); if (workerName == null) { workerName = "XNIO-" + seq.getAndIncrement(); } name = workerName; final boolean markThreadAsDaemon = builder.isDaemon(); bindAddressTable = builder.getBindAddressConfigurations(); final Runnable terminationTask = new Runnable() { public void run() { taskPoolTerminated(); } }; final ExecutorService executorService = builder.getExternalExecutorService(); if (executorService != null) { if (executorService instanceof EnhancedQueueExecutor) { taskPool = new ExternalTaskPool( new EnhancedQueueExecutorTaskPool((EnhancedQueueExecutor) executorService)); } else if (executorService instanceof ThreadPoolExecutor) { taskPool = new ExternalTaskPool(new ThreadPoolExecutorTaskPool((ThreadPoolExecutor) executorService)); } else { taskPool = new ExternalTaskPool(new ExecutorServiceTaskPool(executorService)); } } else if (EnhancedQueueExecutor.DISABLE_HINT) { final int poolSize = max(builder.getMaxWorkerPoolSize(), builder.getCoreWorkerPoolSize()); taskPool = new ThreadPoolExecutorTaskPool(new DefaultThreadPoolExecutor( poolSize, poolSize, builder.getWorkerKeepAlive(), TimeUnit.MILLISECONDS, new LinkedBlockingDeque<>(), new WorkerThreadFactory(builder.getThreadGroup(), builder.getWorkerStackSize(), markThreadAsDaemon), terminationTask)); } else { taskPool = new EnhancedQueueExecutorTaskPool(new EnhancedQueueExecutor.Builder() .setCorePoolSize(builder.getCoreWorkerPoolSize()) .setMaximumPoolSize(builder.getMaxWorkerPoolSize()) .setKeepAliveTime(builder.getWorkerKeepAlive(), TimeUnit.MILLISECONDS) .setThreadFactory(new WorkerThreadFactory(builder.getThreadGroup(), builder.getWorkerStackSize(), markThreadAsDaemon)) .setTerminationTask(terminationTask) .setRegisterMBean(true) .setMBeanName(workerName) .build() ); } }