Package picard.util
Class ThreadPoolExecutorWithExceptions
java.lang.Object
java.util.concurrent.AbstractExecutorService
java.util.concurrent.ThreadPoolExecutor
picard.util.ThreadPoolExecutorWithExceptions
- All Implemented Interfaces:
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 void
afterExecute
(Runnable r, Throwable t) protected void
beforeExecute
(Thread t, Runnable r) void
cleanUp()
Calls `shutdownNow, adjusts the core size to 0 and low timeout to ensure threads get killed and garbage collected.boolean
hasError()
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, toString
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
-
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:
afterExecute
in classThreadPoolExecutor
-
beforeExecute
- Overrides:
beforeExecute
in 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.
-