org.apache.tomcat.util.threads
public class ThreadPool extends Object
| Nested Class Summary | |
|---|---|
| static class | ThreadPool.ControlRunnable
A Thread object that executes various actions ( ThreadPoolRunnable )
under control of ThreadPool |
| static class | ThreadPool.MonitorRunnable
Periodically execute an action - cleanup in this case |
| static interface | ThreadPool.ThreadPoolListener Interface to allow applications to be notified when
a threads are created and stopped. |
| Field Summary | |
|---|---|
| protected int | currentThreadCount |
| protected int | currentThreadsBusy |
| protected boolean | isDaemon |
| protected Vector | listeners |
| protected int | maxSpareThreads |
| protected int | maxThreads |
| protected int | minSpareThreads |
| protected ThreadPool.MonitorRunnable | monitor |
| static int | MAX_SPARE_THREADS |
| static int | MAX_THREADS |
| static int | MAX_THREADS_MIN |
| static int | MIN_SPARE_THREADS |
| protected String | name Name of the threadpool |
| protected ThreadPool.ControlRunnable[] | pool |
| protected int | sequence
Sequence. |
| protected boolean | stopThePool |
| protected int | threadPriority
Thread priority. |
| protected Hashtable | threads The threads that are part of the pool.
|
| static int | WORK_WAIT_TIMEOUT |
| Constructor Summary | |
|---|---|
| ThreadPool()
Constructor. | |
| Method Summary | |
|---|---|
| void | addThread(Thread t, ThreadPool.ControlRunnable cr) |
| void | addThreadPoolListener(ThreadPool.ThreadPoolListener tpl) |
| protected void | adjustLimits() |
| protected void | checkSpareControllers()
Called by the monitor thread to harvest idle threads. |
| static ThreadPool | createThreadPool(boolean jmx) Create a ThreadPool instance.
|
| int | getCurrentThreadCount() |
| int | getCurrentThreadsBusy() |
| boolean | getDaemon() |
| static int | getDebug() |
| int | getMaxSpareThreads() |
| int | getMaxThreads() |
| int | getMinSpareThreads() |
| ThreadPool.MonitorRunnable | getMonitor() |
| String | getName() |
| int | getSequence() |
| String[] | getThreadParam() Return an array with the current "param" ( XXX better name ? |
| int | getThreadPriority()
Returns the priority level of current and
future threads in this pool.
|
| Enumeration | getThreads() |
| String[] | getThreadStatus() Return an array with the status of each thread. |
| int | incSequence() |
| boolean | isDaemon() |
| protected void | notifyThreadEnd(ThreadPool.ControlRunnable c)
Inform the pool that the specific thread finish.
|
| protected void | openThreads(int toOpen) Create missing threads.
|
| void | removeThread(Thread t) |
| protected void | returnController(ThreadPool.ControlRunnable c)
Returns the thread to the pool.
|
| void | run(Runnable r) |
| void | runIt(ThreadPoolRunnable r)
Executes a given Runnable on a thread in the pool, block if needed. |
| void | setDaemon(boolean b) The default is true - the created threads will be
in daemon mode. |
| void | setMaxSpareThreads(int maxSpareThreads) |
| void | setMaxThreads(int maxThreads) |
| void | setMinSpareThreads(int minSpareThreads) |
| void | setName(String name) |
| void | setThreadPriority(int threadPriority)
Sets the thread priority for current
and future threads in this pool.
|
| void | shutdown()
Stop the thread pool |
| void | start() |
| String | threadStatusString()
Debug display of the stage of each thread. |
Parameters: jmx UNUSED
Returns: ThreadPool instance. If JMX support is requested, you need to call register() in order to set a name.
Returns: The params of all threads
Returns: The priority
Returns: The status of all threads
Parameters: toOpen Total number of threads we'll have open
Parameters: threadPriority The new priority
Throws: IllegalArgumentException If the specified priority is less than Thread.MIN_PRIORITY or more than Thread.MAX_PRIORITY
Returns: The thread status display