@ManagedObject(value="A thread pool") public class QueuedThreadPool extends ContainerLifeCycle implements ThreadFactory, ThreadPool.SizedThreadPool, Dumpable, TryExecutor
AbstractLifeCycle.AbstractLifeCycleListenerThreadPool.SizedThreadPoolTryExecutor.NoTryExecutorContainer.InheritedListener, Container.ListenerLifeCycle.ListenerFAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPINGNO_TRY| Constructor and Description |
|---|
QueuedThreadPool() |
QueuedThreadPool(int maxThreads) |
QueuedThreadPool(int maxThreads,
int minThreads) |
QueuedThreadPool(int maxThreads,
int minThreads,
BlockingQueue<Runnable> queue) |
QueuedThreadPool(int maxThreads,
int minThreads,
int idleTimeout) |
QueuedThreadPool(int maxThreads,
int minThreads,
int idleTimeout,
BlockingQueue<Runnable> queue) |
QueuedThreadPool(int maxThreads,
int minThreads,
int idleTimeout,
BlockingQueue<Runnable> queue,
ThreadGroup threadGroup) |
QueuedThreadPool(int maxThreads,
int minThreads,
int idleTimeout,
int reservedThreads,
BlockingQueue<Runnable> queue,
ThreadGroup threadGroup) |
QueuedThreadPool(int maxThreads,
int minThreads,
int idleTimeout,
int reservedThreads,
BlockingQueue<Runnable> queue,
ThreadGroup threadGroup,
ThreadFactory threadFactory) |
| Modifier and Type | Method and Description |
|---|---|
void |
dump(Appendable out,
String indent)
Dump this object (and children) into an Appendable using the provided indent after any new lines.
|
String |
dumpThread(long id) |
void |
execute(Runnable job) |
int |
getBusyThreads() |
int |
getIdleThreads() |
int |
getIdleTimeout()
Get the maximum thread idle time.
|
int |
getLowThreadsThreshold() |
int |
getMaxThreads()
Get the maximum number of threads.
|
int |
getMinThreads()
Get the minimum number of threads.
|
String |
getName() |
int |
getQueueSize()
Get the size of the job queue.
|
int |
getReservedThreads()
Get the number of reserved threads.
|
ThreadPoolBudget |
getThreadPoolBudget() |
int |
getThreads() |
int |
getThreadsPriority()
Get the priority of the pool threads.
|
boolean |
interruptThread(long id) |
boolean |
isDaemon() |
boolean |
isDetailedDump() |
boolean |
isLowOnThreads()
Returns whether this thread pool is low on threads.
|
void |
join()
Blocks until the thread pool is
stopped. |
Thread |
newThread(Runnable runnable) |
void |
setDaemon(boolean daemon)
Thread Pool should use Daemon Threading.
|
void |
setDetailedDump(boolean detailedDump) |
void |
setIdleTimeout(int idleTimeout)
Set the maximum thread idle time.
|
void |
setLowThreadsThreshold(int lowThreadsThreshold) |
void |
setMaxThreads(int maxThreads)
Set the maximum number of threads.
|
void |
setMinThreads(int minThreads)
Set the minimum number of threads.
|
void |
setName(String name) |
void |
setQueue(BlockingQueue<Runnable> queue)
Deprecated.
pass the queue to the constructor instead
|
void |
setReservedThreads(int reservedThreads)
Set the number of reserved threads.
|
void |
setThreadPoolBudget(ThreadPoolBudget budget) |
void |
setThreadsPriority(int priority)
Set the priority of the pool threads.
|
String |
toString() |
boolean |
tryExecute(Runnable task)
Attempt to execute a task.
|
addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dumpObject, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, unmanage, updateBean, updateBean, updateBeansaddLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopequals, getClass, hashCode, notify, notifyAll, wait, wait, waitdump, dump, dumpContainer, dumpIterable, dumpMapEntries, dumpObject, dumpObjects, dumpSelf, namedasTryExecutorpublic QueuedThreadPool()
public QueuedThreadPool(@Name(value="maxThreads") int maxThreads, @Name(value="minThreads") int minThreads)
public QueuedThreadPool(@Name(value="maxThreads") int maxThreads, @Name(value="minThreads") int minThreads, @Name(value="queue") BlockingQueue<Runnable> queue)
public QueuedThreadPool(@Name(value="maxThreads") int maxThreads, @Name(value="minThreads") int minThreads, @Name(value="idleTimeout") int idleTimeout)
public QueuedThreadPool(@Name(value="maxThreads") int maxThreads, @Name(value="minThreads") int minThreads, @Name(value="idleTimeout") int idleTimeout, @Name(value="queue") BlockingQueue<Runnable> queue)
public QueuedThreadPool(@Name(value="maxThreads") int maxThreads, @Name(value="minThreads") int minThreads, @Name(value="idleTimeout") int idleTimeout, @Name(value="queue") BlockingQueue<Runnable> queue, @Name(value="threadGroup") ThreadGroup threadGroup)
public QueuedThreadPool(@Name(value="maxThreads") int maxThreads, @Name(value="minThreads") int minThreads, @Name(value="idleTimeout") int idleTimeout, @Name(value="reservedThreads") int reservedThreads, @Name(value="queue") BlockingQueue<Runnable> queue, @Name(value="threadGroup") ThreadGroup threadGroup)
public QueuedThreadPool(@Name(value="maxThreads") int maxThreads, @Name(value="minThreads") int minThreads, @Name(value="idleTimeout") int idleTimeout, @Name(value="reservedThreads") int reservedThreads, @Name(value="queue") BlockingQueue<Runnable> queue, @Name(value="threadGroup") ThreadGroup threadGroup, @Name(value="threadFactory") ThreadFactory threadFactory)
public ThreadPoolBudget getThreadPoolBudget()
getThreadPoolBudget in interface ThreadPool.SizedThreadPoolpublic void setThreadPoolBudget(ThreadPoolBudget budget)
public void setDaemon(boolean daemon)
daemon - true to enable delegationThread.setDaemon(boolean)public void setIdleTimeout(int idleTimeout)
idleTimeout - Max idle time in ms.getIdleTimeout()public void setMaxThreads(int maxThreads)
setMaxThreads in interface ThreadPool.SizedThreadPoolmaxThreads - maximum number of threads.getMaxThreads()public void setMinThreads(int minThreads)
setMinThreads in interface ThreadPool.SizedThreadPoolminThreads - minimum number of threadsgetMinThreads()public void setReservedThreads(int reservedThreads)
reservedThreads - number of reserved threads or -1 for heuristically determinedgetReservedThreads()public void setName(String name)
name - Name of this thread pool to use when naming threads.public void setThreadsPriority(int priority)
priority - the new thread priority.@ManagedAttribute(value="maximum time a thread may be idle in ms") public int getIdleTimeout()
setIdleTimeout(int)@ManagedAttribute(value="maximum number of threads in the pool") public int getMaxThreads()
getMaxThreads in interface ThreadPool.SizedThreadPoolsetMaxThreads(int)@ManagedAttribute(value="minimum number of threads in the pool") public int getMinThreads()
getMinThreads in interface ThreadPool.SizedThreadPoolsetMinThreads(int)@ManagedAttribute(value="the number of reserved threads in the pool") public int getReservedThreads()
setReservedThreads(int)@ManagedAttribute(value="name of the thread pool") public String getName()
@ManagedAttribute(value="priority of threads in the pool") public int getThreadsPriority()
@ManagedAttribute(value="size of the job queue") public int getQueueSize()
@ManagedAttribute(value="thread pool uses daemon threads") public boolean isDaemon()
Thread.setDaemon(boolean)@ManagedAttribute(value="reports additional details in the dump") public boolean isDetailedDump()
public void setDetailedDump(boolean detailedDump)
@ManagedAttribute(value="threshold at which the pool is low on threads") public int getLowThreadsThreshold()
public void setLowThreadsThreshold(int lowThreadsThreshold)
public void execute(Runnable job)
execute in interface Executorexecute in interface TryExecutorpublic boolean tryExecute(Runnable task)
TryExecutortryExecute in interface TryExecutortask - The task to be executedpublic void join()
throws InterruptedException
stopped.join in interface ThreadPoolInterruptedException - if thread was interrupted@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 ThreadPool@ManagedAttribute(value="number of busy threads in the pool") public int getBusyThreads()
@ManagedAttribute(value="thread pool is low on threads", readonly=true) public boolean isLowOnThreads()
Returns whether this thread pool is low on threads.
The current formula is:
maxThreads - threads + idleThreads - queueSize <= lowThreadsThreshold
isLowOnThreads in interface ThreadPoolgetLowThreadsThreshold()public Thread newThread(Runnable runnable)
newThread in interface ThreadFactorypublic void dump(Appendable out, String indent) throws IOException
Dumpabledump in interface Dumpabledump in class ContainerLifeCycleout - The appendable to dump toindent - The indent to apply after any new lines.IOException - if unable to write to Appendablepublic String toString()
toString in class AbstractLifeCycle@Deprecated public void setQueue(BlockingQueue<Runnable> queue)
queue - the job queue@ManagedOperation(value="interrupts a pool thread") public boolean interruptThread(@Name(value="id") long id)
id - the thread ID to interrupt.@ManagedOperation(value="dumps a pool thread stack") public String dumpThread(@Name(value="id") long id)
id - the thread ID to interrupt.Copyright © 2010 - 2020 Adobe. All Rights Reserved