com.caucho.util
Class ThreadPool

java.lang.Object
  extended by com.caucho.util.ThreadPool

public class ThreadPool
extends java.lang.Object

A generic pool of threads available for Alarms and Work tasks.


Method Summary
 void closeEnvironment(java.lang.ClassLoader env)
          Resets the thread pool, letting old threads drain.
 void completeExecutorTask()
          Called when an executor task completes
 int getExecutorTaskMax()
          Gets the maximum number of executor threads.
 int getFreeThreadCount()
          Returns the free thread count.
 int getThreadActiveCount()
          Returns the active thread count.
 int getThreadCount()
          Returns the total thread count.
 int getThreadIdleCount()
          Returns the idle thread count.
 int getThreadIdleMax()
          Gets the maximum number of idle threads.
 int getThreadIdleMin()
          Gets the minimum number of idle threads.
 int getThreadMax()
          Gets the maximum number of threads.
static ThreadPool getThreadPool()
           
 int getThreadPriority()
           
 void interrupt()
          interrupts all the threads.
 void reset()
          Resets the thread pool, letting old threads drain.
 boolean schedule(java.lang.Runnable task)
          Schedules a new task.
 boolean schedule(java.lang.Runnable task, long timeout)
          Adds a new task.
 boolean scheduleExecutorTask(java.lang.Runnable task)
          Schedules an executor task.
 void schedulePriority(java.lang.Runnable task)
          Adds a new task.
 void setExecutorTaskMax(int max)
          Sets the maximum number of executor threads.
 void setThreadIdleMax(int max)
          Sets the maximum number of idle threads.
 void setThreadIdleMin(int min)
          Sets the minimum number of idle threads.
 void setThreadMax(int max)
          Sets the maximum number of threads.
 void setThreadPriority(int priority)
           
 boolean start(java.lang.Runnable task)
          Adds a new task.
 boolean start(java.lang.Runnable task, long timeout)
          Adds a new task.
 void startPriority(java.lang.Runnable task)
          Adds a new task.
 boolean startPriority(java.lang.Runnable task, long timeout)
          Adds a new task.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getThreadPool

public static ThreadPool getThreadPool()

setThreadMax

public void setThreadMax(int max)
Sets the maximum number of threads.


getThreadMax

public int getThreadMax()
Gets the maximum number of threads.


setThreadIdleMin

public void setThreadIdleMin(int min)
Sets the minimum number of idle threads.


getThreadIdleMin

public int getThreadIdleMin()
Gets the minimum number of idle threads.


setThreadIdleMax

public void setThreadIdleMax(int max)
Sets the maximum number of idle threads.


getThreadIdleMax

public int getThreadIdleMax()
Gets the maximum number of idle threads.


setExecutorTaskMax

public void setExecutorTaskMax(int max)
Sets the maximum number of executor threads.


getExecutorTaskMax

public int getExecutorTaskMax()
Gets the maximum number of executor threads.


setThreadPriority

public void setThreadPriority(int priority)

getThreadPriority

public int getThreadPriority()

getThreadCount

public int getThreadCount()
Returns the total thread count.


getThreadIdleCount

public int getThreadIdleCount()
Returns the idle thread count.


getThreadActiveCount

public int getThreadActiveCount()
Returns the active thread count.


getFreeThreadCount

public int getFreeThreadCount()
Returns the free thread count.


reset

public void reset()
Resets the thread pool, letting old threads drain.


closeEnvironment

public void closeEnvironment(java.lang.ClassLoader env)
Resets the thread pool, letting old threads drain.


schedule

public boolean schedule(java.lang.Runnable task)
Schedules a new task.


schedule

public boolean schedule(java.lang.Runnable task,
                        long timeout)
Adds a new task.


schedulePriority

public void schedulePriority(java.lang.Runnable task)
Adds a new task.


scheduleExecutorTask

public boolean scheduleExecutorTask(java.lang.Runnable task)
Schedules an executor task.


completeExecutorTask

public void completeExecutorTask()
Called when an executor task completes


start

public boolean start(java.lang.Runnable task)
Adds a new task.


start

public boolean start(java.lang.Runnable task,
                     long timeout)
Adds a new task.


startPriority

public void startPriority(java.lang.Runnable task)
Adds a new task.


startPriority

public boolean startPriority(java.lang.Runnable task,
                             long timeout)
Adds a new task.


interrupt

public void interrupt()
interrupts all the threads.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object