Package picard.util
Class ThreadPoolExecutorWithExceptions
java.lang.Object
java.util.concurrent.AbstractExecutorService
java.util.concurrent.ThreadPoolExecutor
picard.util.ThreadPoolExecutorWithExceptions
- All Implemented Interfaces:
AutoCloseable,Executor,ExecutorService
This version of the thread pool executor will throw an exception if any of the internal jobs have throw exceptions
while executing
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionThreadPoolExecutorWithExceptions(int threads) Creates a fixed size thread pool executor that will rethrow exceptions from submitted jobs. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafterExecute(Runnable r, Throwable t) protected voidbeforeExecute(Thread t, Runnable r) voidcleanUp()Calls `shutdownNow, adjusts the core size to 0 and low timeout to ensure threads get killed and garbage collected.booleanhasError()Methods inherited from class java.util.concurrent.ThreadPoolExecutor
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, 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 java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submitMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.concurrent.ExecutorService
close
-
Field Details
-
exception
-
-
Constructor Details
-
ThreadPoolExecutorWithExceptions
public ThreadPoolExecutorWithExceptions(int threads) Creates a fixed size thread pool executor that will rethrow exceptions from submitted jobs.- Parameters:
threads- The number of threads in the executor pool.
-
-
Method Details
-
afterExecute
- Overrides:
afterExecutein classThreadPoolExecutor
-
beforeExecute
- Overrides:
beforeExecutein classThreadPoolExecutor
-
hasError
public boolean hasError() -
cleanUp
public void cleanUp()Calls `shutdownNow, adjusts the core size to 0 and low timeout to ensure threads get killed and garbage collected.
-