public class AutoCloseableExecutorService
extends java.util.concurrent.ThreadPoolExecutor
implements java.lang.AutoCloseable
java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy| Modifier and Type | Field and Description |
|---|---|
InterruptionChecker |
interruptionChecker
The
InterruptionChecker. |
| Constructor and Description |
|---|
AutoCloseableExecutorService(int numThreads)
A ThreadPoolExecutor that can be used in a try-with-resources block.
|
| Modifier and Type | Method and Description |
|---|---|
void |
afterExecute(java.lang.Runnable runnable,
java.lang.Throwable throwable)
Catch exceptions from both submit() and execute(), and call
InterruptionChecker.interrupt() to
interrupt all threads. |
void |
close()
Shut down thread pool on close().
|
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, shutdown, shutdownNow, terminated, toStringpublic final InterruptionChecker interruptionChecker
InterruptionChecker.public AutoCloseableExecutorService(int numThreads)
numThreads - The number of threads to allocate.public void afterExecute(java.lang.Runnable runnable,
java.lang.Throwable throwable)
InterruptionChecker.interrupt() to
interrupt all threads.afterExecute in class java.util.concurrent.ThreadPoolExecutorrunnable - the Runnablethrowable - the Throwablepublic void close()
close in interface java.lang.AutoCloseable