|
Apache Tomcat 6.0.53 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tomcat.util.threads.ThreadPool
public class ThreadPool
A thread pool that is trying to copy the apache process management. Should we remove this in favor of Doug Lea's thread package?
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 java.util.Vector |
listeners
|
static int |
MAX_SPARE_THREADS
|
static int |
MAX_THREADS
|
static int |
MAX_THREADS_MIN
|
protected int |
maxSpareThreads
|
protected int |
maxThreads
|
static int |
MIN_SPARE_THREADS
|
protected int |
minSpareThreads
|
protected ThreadPool.MonitorRunnable |
monitor
|
protected java.lang.String |
name
Name of the threadpool |
protected ThreadPool.ControlRunnable[] |
pool
|
protected int |
sequence
Sequence. |
protected boolean |
stopThePool
|
protected int |
threadPriority
Thread priority. |
protected java.util.Hashtable |
threads
The threads that are part of the pool. |
static int |
WORK_WAIT_TIMEOUT
|
Constructor Summary | |
---|---|
ThreadPool()
Constructor. |
Method Summary | |
---|---|
void |
addThread(java.lang.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()
|
java.lang.String |
getName()
|
int |
getSequence()
|
java.lang.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. |
java.util.Enumeration |
getThreads()
|
java.lang.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(java.lang.Thread t)
|
protected void |
returnController(ThreadPool.ControlRunnable c)
Returns the thread to the pool. |
void |
run(java.lang.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(java.lang.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()
|
java.lang.String |
threadStatusString()
Debug display of the stage of each thread. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MAX_THREADS
public static final int MAX_THREADS_MIN
public static final int MAX_SPARE_THREADS
public static final int MIN_SPARE_THREADS
public static final int WORK_WAIT_TIMEOUT
protected ThreadPool.ControlRunnable[] pool
protected ThreadPool.MonitorRunnable monitor
protected int maxThreads
protected int minSpareThreads
protected int maxSpareThreads
protected int currentThreadCount
protected int currentThreadsBusy
protected boolean stopThePool
protected boolean isDaemon
protected java.util.Hashtable threads
protected java.util.Vector listeners
protected java.lang.String name
protected int sequence
protected int threadPriority
Constructor Detail |
---|
public ThreadPool()
Method Detail |
---|
public static ThreadPool createThreadPool(boolean jmx)
jmx
- UNUSED
public void start()
public ThreadPool.MonitorRunnable getMonitor()
public void setThreadPriority(int threadPriority)
threadPriority
- The new priority
java.lang.IllegalArgumentException
- If the specified
priority is less than Thread.MIN_PRIORITY or
more than Thread.MAX_PRIORITYpublic int getThreadPriority()
public void setMaxThreads(int maxThreads)
public int getMaxThreads()
public void setMinSpareThreads(int minSpareThreads)
public int getMinSpareThreads()
public void setMaxSpareThreads(int maxSpareThreads)
public int getMaxSpareThreads()
public int getCurrentThreadCount()
public int getCurrentThreadsBusy()
public boolean isDaemon()
public static int getDebug()
public void setDaemon(boolean b)
public boolean getDaemon()
public void setName(java.lang.String name)
public java.lang.String getName()
public int getSequence()
public int incSequence()
public void addThread(java.lang.Thread t, ThreadPool.ControlRunnable cr)
public void removeThread(java.lang.Thread t)
public void addThreadPoolListener(ThreadPool.ThreadPoolListener tpl)
public java.util.Enumeration getThreads()
public void run(java.lang.Runnable r)
public void runIt(ThreadPoolRunnable r)
public void shutdown()
protected void checkSpareControllers()
protected void returnController(ThreadPool.ControlRunnable c)
protected void notifyThreadEnd(ThreadPool.ControlRunnable c)
protected void adjustLimits()
protected void openThreads(int toOpen)
toOpen
- Total number of threads we'll have openpublic java.lang.String threadStatusString()
public java.lang.String[] getThreadStatus()
public java.lang.String[] getThreadParam()
|
Apache Tomcat 6.0.53 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |