@ManagedObject(value="A thread pool") public class ExecutorThreadPool extends ContainerLifeCycle implements ThreadPool.SizedThreadPool, TryExecutor
ThreadPool.SizedThreadPool wrapper around ThreadPoolExecutor.AbstractLifeCycle.AbstractLifeCycleListenerThreadPool.SizedThreadPoolTryExecutor.NoTryExecutorContainer.InheritedListener, Container.ListenerLifeCycle.Listener| Modifier and Type | Field and Description |
|---|---|
private ThreadPoolBudget |
_budget |
private boolean |
_daemon |
private boolean |
_detailedDump |
private java.util.concurrent.ThreadPoolExecutor |
_executor |
private java.lang.ThreadGroup |
_group |
private int |
_minThreads |
private java.lang.String |
_name |
private int |
_priority |
private int |
_reservedThreads |
private TryExecutor |
_tryExecutor |
FAILED, RUNNING, STARTED, STARTING, STOP_ON_FAILURE, STOPPED, STOPPINGNO_TRY| Modifier | Constructor and Description |
|---|---|
|
ExecutorThreadPool() |
|
ExecutorThreadPool(int maxThreads) |
|
ExecutorThreadPool(int maxThreads,
int minThreads) |
|
ExecutorThreadPool(java.util.concurrent.ThreadPoolExecutor executor) |
|
ExecutorThreadPool(java.util.concurrent.ThreadPoolExecutor executor,
int reservedThreads) |
private |
ExecutorThreadPool(java.util.concurrent.ThreadPoolExecutor executor,
int minThreads,
int reservedThreads,
java.lang.ThreadGroup group) |
|
ExecutorThreadPool(java.util.concurrent.ThreadPoolExecutor executor,
int reservedThreads,
java.lang.ThreadGroup group) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doStart()
Starts the managed lifecycle beans in the order they were added.
|
protected void |
doStop()
Stops the managed lifecycle beans in the reverse order they were added.
|
void |
dump(java.lang.Appendable out,
java.lang.String indent) |
void |
execute(java.lang.Runnable command) |
int |
getIdleThreads() |
int |
getIdleTimeout() |
int |
getMaxThreads() |
int |
getMinThreads() |
java.lang.String |
getName() |
int |
getReservedThreads() |
ThreadPoolBudget |
getThreadPoolBudget() |
int |
getThreads() |
int |
getThreadsPriority() |
boolean |
isDaemon() |
boolean |
isDetailedDump() |
boolean |
isLowOnThreads() |
void |
join()
Blocks until the thread pool is
stopped. |
protected java.lang.Thread |
newThread(java.lang.Runnable job) |
void |
setDaemon(boolean daemon) |
void |
setDetailedDump(boolean detailedDump) |
void |
setIdleTimeout(int idleTimeout)
Sets the maximum thread idle time in ms.
|
void |
setMaxThreads(int threads) |
void |
setMinThreads(int threads) |
void |
setName(java.lang.String name) |
void |
setReservedThreads(int reservedThreads)
Sets the number of reserved threads.
|
void |
setThreadsPriority(int priority) |
java.lang.String |
toString() |
boolean |
tryExecute(java.lang.Runnable task)
Attempt to execute a task.
|
addBean, addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeansaddLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitasTryExecutorprivate final java.util.concurrent.ThreadPoolExecutor _executor
private final ThreadPoolBudget _budget
private final java.lang.ThreadGroup _group
private java.lang.String _name
private int _minThreads
private int _reservedThreads
private TryExecutor _tryExecutor
private int _priority
private boolean _daemon
private boolean _detailedDump
public ExecutorThreadPool()
public ExecutorThreadPool(int maxThreads)
public ExecutorThreadPool(int maxThreads,
int minThreads)
public ExecutorThreadPool(java.util.concurrent.ThreadPoolExecutor executor)
public ExecutorThreadPool(java.util.concurrent.ThreadPoolExecutor executor,
int reservedThreads)
public ExecutorThreadPool(java.util.concurrent.ThreadPoolExecutor executor,
int reservedThreads,
java.lang.ThreadGroup group)
private ExecutorThreadPool(java.util.concurrent.ThreadPoolExecutor executor,
int minThreads,
int reservedThreads,
java.lang.ThreadGroup group)
@ManagedAttribute(value="name of this thread pool") public java.lang.String getName()
public void setName(java.lang.String name)
name - the name of this thread pool, used to name threads@ManagedAttribute(value="minimum number of threads in the pool") public int getMinThreads()
getMinThreads in interface ThreadPool.SizedThreadPoolpublic void setMinThreads(int threads)
setMinThreads in interface ThreadPool.SizedThreadPoolthreads - the minimum number of threads@ManagedAttribute(value="maximum number of threads in the pool") public int getMaxThreads()
getMaxThreads in interface ThreadPool.SizedThreadPoolpublic void setMaxThreads(int threads)
setMaxThreads in interface ThreadPool.SizedThreadPoolthreads - the maximum number of threads@ManagedAttribute(value="maximum time a thread may be idle in ms") public int getIdleTimeout()
setIdleTimeout(int)public void setIdleTimeout(int idleTimeout)
Sets the maximum thread idle time in ms.
Threads that are idle for longer than this period may be stopped.
idleTimeout - the maximum thread idle time in ms.getIdleTimeout()@ManagedAttribute(value="the number of reserved threads in the pool") public int getReservedThreads()
setReservedThreads(int)public void setReservedThreads(int reservedThreads)
reservedThreads - number of reserved threads or -1 to determine the number heuristicallygetReservedThreads()public void setThreadsPriority(int priority)
public int getThreadsPriority()
@ManagedAttribute(value="whether this thread pool uses daemon threads") public boolean isDaemon()
setDaemon(boolean)public void setDaemon(boolean daemon)
daemon - whether this thread pool uses daemon threadsThread.setDaemon(boolean)@ManagedAttribute(value="reports additional details in the dump") public boolean isDetailedDump()
public void setDetailedDump(boolean detailedDump)
@ManagedAttribute(value="number of threads in the pool") public int getThreads()
getThreads in interface ThreadPool@ManagedAttribute(value="number of idle threads in the pool") public int getIdleThreads()
getIdleThreads in interface ThreadPoolpublic void execute(java.lang.Runnable command)
execute in interface java.util.concurrent.Executorexecute in interface TryExecutorpublic boolean tryExecute(java.lang.Runnable task)
TryExecutortryExecute in interface TryExecutortask - The task to be executed@ManagedAttribute(value="thread pool is low on threads", readonly=true) public boolean isLowOnThreads()
isLowOnThreads in interface ThreadPoolprotected void doStart()
throws java.lang.Exception
ContainerLifeCycledoStart in class ContainerLifeCyclejava.lang.Exceptionprotected void doStop()
throws java.lang.Exception
ContainerLifeCycledoStop in class ContainerLifeCyclejava.lang.Exceptionpublic void join()
throws java.lang.InterruptedException
ThreadPoolstopped.join in interface ThreadPooljava.lang.InterruptedException - if thread was interruptedpublic ThreadPoolBudget getThreadPoolBudget()
getThreadPoolBudget in interface ThreadPool.SizedThreadPoolprotected java.lang.Thread newThread(java.lang.Runnable job)
public void dump(java.lang.Appendable out,
java.lang.String indent)
throws java.io.IOException
dump in interface Dumpabledump in class ContainerLifeCyclejava.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.Object