Class AutoCloseableExecutorService
java.lang.Object
java.util.concurrent.AbstractExecutorService
java.util.concurrent.ThreadPoolExecutor
nonapi.io.github.classgraph.concurrency.AutoCloseableExecutorService
- All Implemented Interfaces:
AutoCloseable, Executor, ExecutorService
A ThreadPoolExecutor that can be used in a try-with-resources block.
-
Nested Class Summary
Nested classes/interfaces inherited from class ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAutoCloseableExecutorService(int numThreads) A ThreadPoolExecutor that can be used in a try-with-resources block. -
Method Summary
Modifier and TypeMethodDescriptionvoidafterExecute(Runnable runnable, Throwable throwable) Catch exceptions from both submit() and execute(), and callInterruptionChecker.interrupt()to interrupt all threads.voidclose()Shut down thread pool on close().Methods inherited from class ThreadPoolExecutor
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, toStringMethods inherited from class AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
-
Field Details
-
interruptionChecker
TheInterruptionChecker.
-
-
Constructor Details
-
AutoCloseableExecutorService
public AutoCloseableExecutorService(int numThreads) A ThreadPoolExecutor that can be used in a try-with-resources block.- Parameters:
numThreads- The number of threads to allocate.
-
-
Method Details
-
afterExecute
Catch exceptions from both submit() and execute(), and callInterruptionChecker.interrupt()to interrupt all threads.- Overrides:
afterExecutein classThreadPoolExecutor- Parameters:
runnable- the Runnablethrowable- the Throwable
-
close
public void close()Shut down thread pool on close().- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceExecutorService
-