public class AFThreadPoolExecutor
extends java.util.concurrent.ThreadPoolExecutor
LoggingFuture. A
LoggingFuture logs an occurred exception if no one retrieved the
exception. This way the exception will not be lost. Additionally, it will log
if the result is relevant but no one retrieved it. java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy| Modifier and Type | Field and Description |
|---|---|
protected java.util.concurrent.atomic.AtomicLong |
activeThreads
The amount of active threads.
|
protected java.util.concurrent.atomic.AtomicLong |
completedTasks
The amount of all tasks that have been completed.
|
protected java.util.concurrent.atomic.AtomicLong |
submittedTasks
The amount of all tasks that have been submitted (known via
execute(Runnable). |
| Constructor and Description |
|---|
AFThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
Adept2ThreadFactory threadFactory,
int queueLimit)
Creates a new AFThreadPoolExecutor with the given initial
parameters and default rejected execution handler.
|
AFThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
Adept2ThreadFactory threadFactory,
java.util.concurrent.RejectedExecutionHandler handler,
int queueLimit)
Creates a new ThreadPoolExecutor with the given initial
parameters.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterExecute(java.lang.Runnable r,
java.lang.Throwable t) |
protected void |
beforeExecute(java.lang.Thread t,
java.lang.Runnable r) |
void |
execute(java.lang.Runnable command) |
protected <T> java.util.concurrent.RunnableFuture<T> |
newTaskFor(java.util.concurrent.Callable<T> callable) |
protected <T> java.util.concurrent.RunnableFuture<T> |
newTaskFor(java.lang.Runnable runnable,
T value) |
boolean |
setLogExecuteCallStack(boolean logExecuteCallStack)
Sets whether to log the stack of the caller of
execute(Runnable). |
void |
updateQueueLimit(int limit)
Update the queue limit to inform the thread pool about a changed situation,
i.e. the initial worklist update is completed.
|
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, 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, toStringprotected final java.util.concurrent.atomic.AtomicLong submittedTasks
execute(Runnable).protected final java.util.concurrent.atomic.AtomicLong completedTasks
protected final java.util.concurrent.atomic.AtomicLong activeThreads
public AFThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
Adept2ThreadFactory threadFactory,
int queueLimit)
corePoolSize - the number of threads to keep in the pool, even if they
are idle.maximumPoolSize - the maximum number of threads to allow in the pool.keepAliveTime - when the number of threads is greater than the core,
this is the maximum time that excess idle threads will wait for
new tasks before terminating.unit - the time unit for the keepAliveTime argument.workQueue - the queue to use for holding tasks before they are
executed. This queue will hold only the Runnable tasks
submitted by the execute method.threadFactory - the factory to use when the executor creates a new
thread.queueLimit - The amount of tasks in the queue before warnings will be
logged. Use -1 to use the default limits.java.lang.IllegalArgumentException - if corePoolSize or keepAliveTime less than
zero, or if maximumPoolSize less than or equal to zero, or if
corePoolSize greater than maximumPoolSize.java.lang.NullPointerException - if workQueue or
threadFactory are null.public AFThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
Adept2ThreadFactory threadFactory,
java.util.concurrent.RejectedExecutionHandler handler,
int queueLimit)
corePoolSize - the number of threads to keep in the pool, even if they
are idle.maximumPoolSize - the maximum number of threads to allow in the pool.keepAliveTime - when the number of threads is greater than the core,
this is the maximum time that excess idle threads will wait for
new tasks before terminating.unit - the time unit for the keepAliveTime argument.workQueue - the queue to use for holding tasks before they are
executed. This queue will hold only the Runnable tasks
submitted by the execute method.threadFactory - the factory to use when the executor creates a new
thread.handler - the handler to use when execution is blocked because the
thread bounds and queue capacities are reached.queueLimit - The amount of tasks in the queue before warnings will be
logged. Use -1 to use the default limits.java.lang.IllegalArgumentException - if corePoolSize or keepAliveTime less than
zero, or if maximumPoolSize less than or equal to zero, or if
corePoolSize greater than maximumPoolSize.java.lang.NullPointerException - if workQueue or
threadFactory or handler are null.protected void beforeExecute(java.lang.Thread t,
java.lang.Runnable r)
beforeExecute in class java.util.concurrent.ThreadPoolExecutorpublic void execute(java.lang.Runnable command)
execute in interface java.util.concurrent.Executorexecute in class java.util.concurrent.ThreadPoolExecutorprotected <T> java.util.concurrent.RunnableFuture<T> newTaskFor(java.lang.Runnable runnable,
T value)
newTaskFor in class java.util.concurrent.AbstractExecutorServiceprotected <T> java.util.concurrent.RunnableFuture<T> newTaskFor(java.util.concurrent.Callable<T> callable)
newTaskFor in class java.util.concurrent.AbstractExecutorServiceprotected void afterExecute(java.lang.Runnable r,
java.lang.Throwable t)
afterExecute in class java.util.concurrent.ThreadPoolExecutorpublic void updateQueueLimit(int limit)
limit - The new queue limit.public boolean setLogExecuteCallStack(boolean logExecuteCallStack)
execute(Runnable). This allows to
identify which code parts have enqueued some asynchronous work. The logger requires
Level.FINE for this.logExecuteCallStack - Whether to log the stack of the caller of
execute(Runnable).logExecuteCallStack.