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, toStringinvokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submitprotected 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 Executorexecute in class ThreadPoolExecutorprotected void afterExecute(Runnable r, Throwable t)
afterExecute in class ThreadPoolExecutorpublic void awaitCompletion()
throws InterruptedException
InterruptedExceptionpublic void awaitCompletion(long timeout,
TimeUnit unit)
throws InterruptedException
InterruptedExceptionpublic Throwable getException()
Copyright © 2021 Secure Software Engineering Group - University of Paderborn. All rights reserved.