org.apache.tomcat.util.threads
Class ThreadPool

java.lang.Object
  extended byorg.apache.tomcat.util.threads.ThreadPool

public class ThreadPool
extends java.lang.Object

A thread pool that is trying to copy the apache process management.

Author:
Gal Shachor

Field Summary
protected  int currentThreadCount
           
protected  int currentThreadsBusy
           
static int MAX_SPARE_THREADS
           
static int MAX_THREADS
           
protected  int maxSpareThreads
           
protected  int maxThreads
           
static int MIN_SPARE_THREADS
           
protected  int minSpareThreads
           
protected  org.apache.tomcat.util.threads.ThreadPool.MonitorRunnable monitor
           
protected  java.util.Vector pool
           
protected  boolean stopThePool
           
static int WORK_WAIT_TIMEOUT
           
 
Constructor Summary
ThreadPool()
           
 
Method Summary
protected  void adjustLimits()
           
protected  void checkSpareControllers()
          Called by the monitor thread to harvest idle threads.
 int getMaxSpareThreads()
           
 int getMaxThreads()
           
 int getMinSpareThreads()
           
static void logFull(Log loghelper, int currentThreadCount, int maxThreads)
           
protected  void notifyThreadEnd(org.apache.tomcat.util.threads.ThreadPool.ControlRunnable c)
          Inform the pool that the specific thread finish.
protected  void openThreads(int toOpen)
           
protected  void returnController(org.apache.tomcat.util.threads.ThreadPool.ControlRunnable c)
          Returns the thread to the pool.
 void runIt(ThreadPoolRunnable r)
          Executes a given Runnable on a thread in the pool, block if needed.
 void setMaxSpareThreads(int maxSpareThreads)
           
 void setMaxThreads(int maxThreads)
           
 void setMinSpareThreads(int minSpareThreads)
           
 void shutdown()
          Stop the thread pool
 void start()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_THREADS

public static final int MAX_THREADS
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 java.util.Vector pool

monitor

protected org.apache.tomcat.util.threads.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
Constructor Detail

ThreadPool

public ThreadPool()
Method Detail

start

public void start()

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()

runIt

public void runIt(ThreadPoolRunnable r)
Executes a given Runnable on a thread in the pool, block if needed.


logFull

public static void logFull(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(org.apache.tomcat.util.threads.ThreadPool.ControlRunnable c)
Returns the thread to the pool. Called by threads as they are becoming idel.


notifyThreadEnd

protected void notifyThreadEnd(org.apache.tomcat.util.threads.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)


Copyright © 2001 Apache Software Foundation. All Rights Reserved.