public class ThreadPoolExecutorBase extends java.util.concurrent.ThreadPoolExecutor implements ResizableThreadPool
ThreadPoolExecutorPlus
, or in rare exceptions this class.
This class provides some very basic improvements:
ThreadPoolExecutorBuilder
RejectedExecutionException
RunnableFuture
rejected due to executor shutdown will be cancelled
RunnableFuture
removed by shutdownNow()
will be cancelled
We also provide a shutdown hook for JMX registration cleanup.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 |
---|---|
static java.util.concurrent.RejectedExecutionHandler |
blockingExecutionHandler |
Constructor and Description |
---|
ThreadPoolExecutorBase(int threads,
int keepAlive,
java.util.concurrent.TimeUnit keepAliveUnits,
java.util.concurrent.BlockingQueue<java.lang.Runnable> queue,
NamedThreadFactory threadFactory) |
ThreadPoolExecutorBase(ThreadPoolExecutorBuilder<?> builder) |
Modifier and Type | Method and Description |
---|---|
int |
getActiveTaskCount()
Returns the approximate number of threads that are actively
executing tasks.
|
int |
getCoreThreads() |
int |
getMaximumThreads() |
int |
getPendingTaskCount()
Returns the approximate total of tasks waiting to be executed.
|
NamedThreadFactory |
getThreadFactory() |
java.lang.Runnable |
onShutdown() |
void |
onShutdown(java.lang.Runnable onShutdown) |
void |
setCoreThreads(int number) |
void |
setMaximumThreads(int number) |
void |
shutdown() |
java.util.List<java.lang.Runnable> |
shutdownNow() |
protected void |
terminated() |
java.lang.String |
toString() |
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getCompletedTaskCount, getCorePoolSize, getMaximumPoolSize, getMaxTasksQueued, setCorePoolSize, setMaximumPoolSize
public static final java.util.concurrent.RejectedExecutionHandler blockingExecutionHandler
public ThreadPoolExecutorBase(ThreadPoolExecutorBuilder<?> builder)
public ThreadPoolExecutorBase(int threads, int keepAlive, java.util.concurrent.TimeUnit keepAliveUnits, java.util.concurrent.BlockingQueue<java.lang.Runnable> queue, NamedThreadFactory threadFactory)
public void onShutdown(java.lang.Runnable onShutdown)
public java.lang.Runnable onShutdown()
protected void terminated()
terminated
in class java.util.concurrent.ThreadPoolExecutor
public void shutdown()
shutdown
in interface java.util.concurrent.ExecutorService
shutdown
in class java.util.concurrent.ThreadPoolExecutor
public java.util.List<java.lang.Runnable> shutdownNow()
shutdownNow
in interface java.util.concurrent.ExecutorService
shutdownNow
in class java.util.concurrent.ThreadPoolExecutor
public int getActiveTaskCount()
ResizableThreadPool
getActiveTaskCount
in interface ResizableThreadPool
public int getPendingTaskCount()
ResizableThreadPool
getPendingTaskCount
in interface ResizableThreadPool
public int getCoreThreads()
public void setCoreThreads(int number)
public int getMaximumThreads()
public void setMaximumThreads(int number)
public NamedThreadFactory getThreadFactory()
getThreadFactory
in class java.util.concurrent.ThreadPoolExecutor
public java.lang.String toString()
toString
in class java.util.concurrent.ThreadPoolExecutor
Copyright © 2009- The Apache Software Foundation