Class AutoCloseableExecutorService
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- java.util.concurrent.ThreadPoolExecutor
-
- nonapi.io.github.classgraph.concurrency.AutoCloseableExecutorService
-
- All Implemented Interfaces:
java.lang.AutoCloseable,java.util.concurrent.Executor,java.util.concurrent.ExecutorService
public class AutoCloseableExecutorService extends java.util.concurrent.ThreadPoolExecutor implements java.lang.AutoCloseableA ThreadPoolExecutor that can be used in a try-with-resources block.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy
-
-
Field Summary
Fields Modifier and Type Field Description InterruptionCheckerinterruptionCheckerTheInterruptionChecker.
-
Constructor Summary
Constructors Constructor Description AutoCloseableExecutorService(int numThreads)A ThreadPoolExecutor that can be used in a try-with-resources block.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterExecute(java.lang.Runnable runnable, java.lang.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 java.util.concurrent.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, toString
-
-
-
-
Field Detail
-
interruptionChecker
public final InterruptionChecker interruptionChecker
TheInterruptionChecker.
-
-
Method Detail
-
afterExecute
public void afterExecute(java.lang.Runnable runnable, java.lang.Throwable throwable)Catch exceptions from both submit() and execute(), and callInterruptionChecker.interrupt()to interrupt all threads.- Overrides:
afterExecutein classjava.util.concurrent.ThreadPoolExecutor- Parameters:
runnable- the Runnablethrowable- the Throwable
-
close
public void close()
Shut down thread pool on close().- Specified by:
closein interfacejava.lang.AutoCloseable
-
-