|
|||||||||
| Home >> All >> org >> apache >> tomcat >> util >> [ threads overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.tomcat.util.threads
Class ThreadPool

java.lang.Objectorg.apache.tomcat.util.threads.ThreadPool
- public class ThreadPool
- extends java.lang.Object
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
|
private static org.apache.commons.logging.Log |
log
|
private static boolean |
logfull
|
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. |
private static org.apache.tomcat.util.res.StringManager |
sm
|
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. |
private ThreadPool.ControlRunnable |
findControlRunnable()
|
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 ? ) of each thread. |
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. |
boolean |
isDaemon()
|
(package private) void |
log(java.lang.String s)
Deprecated. |
private static void |
logFull(org.apache.commons.logging.Log loghelper,
int currentThreadCount,
int maxThreads)
|
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 |
log
private static org.apache.commons.logging.Log log
sm
private static org.apache.tomcat.util.res.StringManager sm
logfull
private static boolean logfull
MAX_THREADS
public static final int MAX_THREADS
- See Also:
- Constant Field Values
MAX_THREADS_MIN
public static final int MAX_THREADS_MIN
- See Also:
- Constant Field Values
MAX_SPARE_THREADS
public static final int MAX_SPARE_THREADS
- See Also:
- Constant Field Values
MIN_SPARE_THREADS
public static final int MIN_SPARE_THREADS
- See Also:
- Constant Field Values
WORK_WAIT_TIMEOUT
public static final int WORK_WAIT_TIMEOUT
- See Also:
- Constant Field Values
pool
protected ThreadPool.ControlRunnable[] pool
monitor
protected ThreadPool.MonitorRunnable monitor
maxThreads
protected int maxThreads
minSpareThreads
protected int minSpareThreads
maxSpareThreads
protected int maxSpareThreads
currentThreadCount
protected int currentThreadCount
currentThreadsBusy
protected int currentThreadsBusy
stopThePool
protected boolean stopThePool
isDaemon
protected boolean isDaemon
threads
protected java.util.Hashtable threads
- The threads that are part of the pool.
Key is Thread, value is the ControlRunnable
listeners
protected java.util.Vector listeners
name
protected java.lang.String name
- Name of the threadpool
sequence
protected int sequence
- Sequence.
threadPriority
protected int threadPriority
- Thread priority.
| Constructor Detail |
ThreadPool
public ThreadPool()
- Constructor.
| Method Detail |
createThreadPool
public static ThreadPool createThreadPool(boolean jmx)
- Create a ThreadPool instance.
start
public void start()
getMonitor
public ThreadPool.MonitorRunnable getMonitor()
setThreadPriority
public void setThreadPriority(int threadPriority)
- Sets the thread priority for current
and future threads in this pool.
getThreadPriority
public int getThreadPriority()
- Returns the priority level of current and
future threads in this pool.
setMaxThreads
public void setMaxThreads(int maxThreads)
getMaxThreads
public int getMaxThreads()
setMinSpareThreads
public void setMinSpareThreads(int minSpareThreads)
getMinSpareThreads
public int getMinSpareThreads()
setMaxSpareThreads
public void setMaxSpareThreads(int maxSpareThreads)
getMaxSpareThreads
public int getMaxSpareThreads()
getCurrentThreadCount
public int getCurrentThreadCount()
getCurrentThreadsBusy
public int getCurrentThreadsBusy()
isDaemon
public boolean isDaemon()
getDebug
public static int getDebug()
setDaemon
public void setDaemon(boolean b)
- The default is true - the created threads will be
in daemon mode. If set to false, the control thread
will not be daemon - and will keep the process alive.
getDaemon
public boolean getDaemon()
setName
public void setName(java.lang.String name)
getName
public java.lang.String getName()
getSequence
public int getSequence()
addThread
public void addThread(java.lang.Thread t, ThreadPool.ControlRunnable cr)
removeThread
public void removeThread(java.lang.Thread t)
addThreadPoolListener
public void addThreadPoolListener(ThreadPool.ThreadPoolListener tpl)
getThreads
public java.util.Enumeration getThreads()
run
public void run(java.lang.Runnable r)
runIt
public void runIt(ThreadPoolRunnable r)
- Executes a given Runnable on a thread in the pool, block if needed.
findControlRunnable
private ThreadPool.ControlRunnable findControlRunnable()
logFull
private static void logFull(org.apache.commons.logging.Log loghelper, int currentThreadCount, int maxThreads)
shutdown
public void shutdown()
- Stop the thread pool
checkSpareControllers
protected void checkSpareControllers()
- Called by the monitor thread to harvest idle threads.
returnController
protected void returnController(ThreadPool.ControlRunnable c)
- Returns the thread to the pool.
Called by threads as they are becoming idel.
notifyThreadEnd
protected void notifyThreadEnd(ThreadPool.ControlRunnable c)
- Inform the pool that the specific thread finish.
Called by the ControlRunnable.run() when the runnable
throws an exception.
adjustLimits
protected void adjustLimits()
openThreads
protected void openThreads(int toOpen)
- Create missing threads.
log
void log(java.lang.String s)
- Deprecated.
threadStatusString
public java.lang.String threadStatusString()
- Debug display of the stage of each thread. The return is html style,
for display in the console ( it can be easily parsed too ).
getThreadStatus
public java.lang.String[] getThreadStatus()
- Return an array with the status of each thread. The status
indicates the current request processing stage ( for tomcat ) or
whatever the thread is doing ( if the application using TP provide
this info )
getThreadParam
public java.lang.String[] getThreadParam()
- Return an array with the current "param" ( XXX better name ? )
of each thread. This is typically the last request.
|
|||||||||
| Home >> All >> org >> apache >> tomcat >> util >> [ threads overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.apache.tomcat.util.threads.ThreadPool