Save This Page
Home » apache-tomcat-6.0.26-src » org.apache » tomcat » util » threads » [javadoc | source]
org.apache.tomcat.util.threads
public class: ThreadPool [javadoc | source]
java.lang.Object
   org.apache.tomcat.util.threads.ThreadPool

Direct Known Subclasses:
    ThreadPoolMX

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:
public static class  ThreadPool.MonitorRunnable  Periodically execute an action - cleanup in this case 
public static class  ThreadPool.ControlRunnable  A Thread object that executes various actions ( ThreadPoolRunnable ) under control of ThreadPool 
public static interface  ThreadPool.ThreadPoolListener  Interface to allow applications to be notified when a threads are created and stopped. 
Field Summary
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  ControlRunnable[] pool     
protected  MonitorRunnable monitor     
protected  int maxThreads     
protected  int minSpareThreads     
protected  int maxSpareThreads     
protected  int currentThreadCount     
protected  int currentThreadsBusy     
protected  boolean stopThePool     
protected  boolean isDaemon     
protected  Hashtable threads    The threads that are part of the pool. Key is Thread, value is the ControlRunnable 
protected  Vector listeners     
protected  String name    Name of the threadpool 
protected  int sequence    Sequence. 
protected  int threadPriority    Thread priority. 
Constructor:
 public ThreadPool() 
Method from org.apache.tomcat.util.threads.ThreadPool Summary:
addThread,   addThreadPoolListener,   adjustLimits,   checkSpareControllers,   createThreadPool,   getCurrentThreadCount,   getCurrentThreadsBusy,   getDaemon,   getDebug,   getMaxSpareThreads,   getMaxThreads,   getMinSpareThreads,   getMonitor,   getName,   getSequence,   getThreadParam,   getThreadPriority,   getThreadStatus,   getThreads,   incSequence,   isDaemon,   log,   notifyThreadEnd,   openThreads,   removeThread,   returnController,   run,   runIt,   setDaemon,   setMaxSpareThreads,   setMaxThreads,   setMinSpareThreads,   setName,   setThreadPriority,   shutdown,   start,   threadStatusString
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.tomcat.util.threads.ThreadPool Detail:
 public  void addThread(Thread t,
    ControlRunnable cr) 
 public  void addThreadPoolListener(ThreadPoolListener tpl) 
 protected  void adjustLimits() 
 protected synchronized  void checkSpareControllers() 
    Called by the monitor thread to harvest idle threads.
 public static ThreadPool createThreadPool(boolean jmx) 
    Create a ThreadPool instance.
 public int getCurrentThreadCount() 
 public int getCurrentThreadsBusy() 
 public boolean getDaemon() 
 public static int getDebug() 
 public int getMaxSpareThreads() 
 public int getMaxThreads() 
 public int getMinSpareThreads() 
 public MonitorRunnable getMonitor() 
 public String getName() 
 public int getSequence() 
 public String[] getThreadParam() 
    Return an array with the current "param" ( XXX better name ? ) of each thread. This is typically the last request.
 public int getThreadPriority() 
    Returns the priority level of current and future threads in this pool.
 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 )
 public Enumeration getThreads() 
 public int incSequence() 
 public boolean isDaemon() 
  void log(String s) 
Deprecated!
 protected synchronized  void notifyThreadEnd(ControlRunnable c) 
    Inform the pool that the specific thread finish. Called by the ControlRunnable.run() when the runnable throws an exception.
 protected  void openThreads(int toOpen) 
    Create missing threads.
 public  void removeThread(Thread t) 
 protected synchronized  void returnController(ControlRunnable c) 
    Returns the thread to the pool. Called by threads as they are becoming idel.
 public  void run(Runnable r) 
 public  void runIt(ThreadPoolRunnable r) 
    Executes a given Runnable on a thread in the pool, block if needed.
 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.
 public  void setMaxSpareThreads(int maxSpareThreads) 
 public  void setMaxThreads(int maxThreads) 
 public  void setMinSpareThreads(int minSpareThreads) 
 public  void setName(String name) 
 public synchronized  void setThreadPriority(int threadPriority) 
    Sets the thread priority for current and future threads in this pool.
 public synchronized  void shutdown() 
    Stop the thread pool
 public synchronized  void start() 
 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 ).