A thread pool that is trying to copy the apache process management.
Should we remove this in favor of Doug Lea's thread package?
MAX_SPARE_THREADS
public static final int MAX_SPARE_THREADS
- 50
MAX_THREADS
public static final int MAX_THREADS
- 200
MAX_THREADS_MIN
public static final int MAX_THREADS_MIN
- 10
MIN_SPARE_THREADS
public static final int MIN_SPARE_THREADS
- 4
WORK_WAIT_TIMEOUT
public static final int WORK_WAIT_TIMEOUT
- 60000
currentThreadCount
protected int currentThreadCount
currentThreadsBusy
protected int currentThreadsBusy
isDaemon
protected boolean isDaemon
listeners
protected Vector listeners
maxSpareThreads
protected int maxSpareThreads
maxThreads
protected int maxThreads
minSpareThreads
protected int minSpareThreads
name
protected String name
Name of the threadpool
sequence
protected int sequence
Sequence.
stopThePool
protected boolean stopThePool
threadPriority
protected int threadPriority
Thread priority.
threads
protected Hashtable threads
The threads that are part of the pool.
Key is Thread, value is the ControlRunnable
adjustLimits
protected void adjustLimits()
checkSpareControllers
protected void checkSpareControllers()
Called by the monitor thread to harvest idle threads.
createThreadPool
public static ThreadPool createThreadPool(boolean jmx)
Create a ThreadPool instance.
jmx
- UNUSED
- ThreadPool instance. If JMX support is requested, you need to
call register() in order to set a name.
getCurrentThreadCount
public int getCurrentThreadCount()
getCurrentThreadsBusy
public int getCurrentThreadsBusy()
getDaemon
public boolean getDaemon()
getDebug
public static int getDebug()
getMaxSpareThreads
public int getMaxSpareThreads()
getMaxThreads
public int getMaxThreads()
getMinSpareThreads
public int getMinSpareThreads()
getName
public String getName()
getSequence
public int getSequence()
getThreadParam
public String[] getThreadParam()
Return an array with the current "param" ( XXX better name ? )
of each thread. This is typically the last request.
getThreadPriority
public int getThreadPriority()
Returns the priority level of current and
future threads in this pool.
- The priority
getThreadStatus
public 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 )
getThreads
public Enumeration getThreads()
isDaemon
public boolean isDaemon()
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.
openThreads
protected void openThreads(int toOpen)
Create missing threads.
toOpen
- Total number of threads we'll have open
removeThread
public void removeThread(Thread t)
returnController
protected void returnController(ThreadPool.ControlRunnable c)
Returns the thread to the pool.
Called by threads as they are becoming idel.
run
public void run(Runnable r)
runIt
public void runIt(ThreadPoolRunnable r)
Executes a given Runnable on a thread in the pool, block if needed.
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.
setMaxSpareThreads
public void setMaxSpareThreads(int maxSpareThreads)
setMaxThreads
public void setMaxThreads(int maxThreads)
setMinSpareThreads
public void setMinSpareThreads(int minSpareThreads)
setName
public void setName(String name)
setThreadPriority
public void setThreadPriority(int threadPriority)
Sets the thread priority for current
and future threads in this pool.
threadPriority
- The new priority
shutdown
public void shutdown()
Stop the thread pool
threadStatusString
public 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 )