public final class DaemonThreadPool extends ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy| Constructor and Description |
|---|
DaemonThreadPool(int coreSize,
long keepAliveSecs,
int shutdownWaitSeconds,
String namePrefix)
Construct the DaemonThreadPool.
|
| Modifier and Type | Method and Description |
|---|---|
void |
registerShutdownHook()
Register a shutdown hook with the JVM Runtime.
|
void |
shutdown()
Shutdown this thread pool nicely if possible.
|
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdownNow, terminated, toStringinvokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submitpublic DaemonThreadPool(int coreSize,
long keepAliveSecs,
int shutdownWaitSeconds,
String namePrefix)
coreSize - the core size of the thread pool.keepAliveSecs - the time in seconds idle threads are keep aliveshutdownWaitSeconds - the time in seconds allowed for the pool to shutdown nicely. After
this the pool is forced to shutdown.public void registerShutdownHook()
public void shutdown()
This will wait a maximum of 20 seconds before terminating any threads still working.
shutdown in interface ExecutorServiceshutdown in class ThreadPoolExecutorCopyright © 2014. All Rights Reserved.