public class CountingThreadPoolExecutor extends ThreadPoolExecutor
ThreadPoolExecutor
which keeps track of the number of spawned
tasks to allow clients to await their completion.ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
Modifier and Type | Field and Description |
---|---|
protected Throwable |
exception |
protected static org.slf4j.Logger |
logger |
protected CountLatch |
numRunningTasks |
Constructor and Description |
---|
CountingThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue) |
Modifier and Type | Method and Description |
---|---|
protected void |
afterExecute(Runnable r,
Throwable t) |
void |
awaitCompletion()
Awaits the completion of all spawned tasks.
|
void |
awaitCompletion(long timeout,
TimeUnit unit)
Awaits the completion of all spawned tasks.
|
void |
execute(Runnable command) |
Throwable |
getException()
Returns the exception thrown during task execution (if any).
|
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, 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
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
protected static final org.slf4j.Logger logger
protected final CountLatch numRunningTasks
protected volatile Throwable exception
public CountingThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)
public void execute(Runnable command)
execute
in interface Executor
execute
in class ThreadPoolExecutor
protected void afterExecute(Runnable r, Throwable t)
afterExecute
in class ThreadPoolExecutor
public void awaitCompletion() throws InterruptedException
InterruptedException
public void awaitCompletion(long timeout, TimeUnit unit) throws InterruptedException
InterruptedException
public Throwable getException()
Copyright © 2021 Secure Software Engineering Group - University of Paderborn. All rights reserved.