com.caucho.env.thread
Class ThreadPool

java.lang.Object
  extended by com.caucho.env.thread.ThreadPool

public final class ThreadPool
extends java.lang.Object

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


Field Summary
static java.lang.String THREAD_FULL_EVENT
           
 
Constructor Summary
ThreadPool()
           
ThreadPool(java.lang.String name)
           
 
Method Summary
 void close()
          Checks if the launcher should start another thread.
 void closeEnvironment(java.lang.ClassLoader env)
          Resets the thread pool, letting old threads drain.
 void completeExecutorTask()
          Called when an executor task completes
static ThreadPool getCurrent()
           
 int getExecutorTaskMax()
          Gets the maximum number of executor threads.
 int getFreeThreadCount()
          Returns the free thread count.
 int getIdleMax()
          Returns the thread idle max.
 int getIdleMin()
          Gets the minimum number of idle threads.
 long getIdleTimeout()
          Returns the idle timeout.
 int getPriorityIdleCount()
          Returns the priority idle thread count.
 int getPriorityIdleMin()
           
 ThreadRing getRing()
           
 int getThreadActiveCount()
          Returns the active thread count.
 int getThreadCount()
          Returns the total thread count.
 long getThreadCreateCountTotal()
          Returns the total created thread count.
 int getThreadIdleCount()
          Returns the idle thread count.
 int getThreadMax()
          Gets the maximum number of threads.
 long getThreadOverflowCountTotal()
          Returns the total created overflow thread count.
static ThreadPool getThreadPool()
           
 int getThreadPriorityQueueSize()
          Returns priority queue size
 int getThreadStartingCount()
          Returns the starting thread count.
 int getThreadTaskQueueSize()
          Returns task queue size
 int getThreadWaitCount()
          Returns the waiting thread count.
 void interrupt()
          interrupts all the idle 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, java.lang.ClassLoader loader)
          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 setIdleMax(int idleMax)
          Returns the thread idle max.
 void setIdleMin(int min)
          Sets the minimum number of idle threads.
 void setIdleTimeout(long timeout)
          Sets the idle timeout
 void setPriorityIdleMin(int priority)
          Sets the minimum number of free threads reserved for priority tasks.
 void setThreadMax(int max)
          Sets the maximum number of threads.
 void setThrottleLimit(int limit)
          Sets the throttle limit.
 void setThrottlePeriod(long period)
          Sets the throttle period.
 void setThrottleSleepTime(long period)
          Sets the throttle sleep time.
 void start()
           
 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
 

Field Detail

THREAD_FULL_EVENT

public static final java.lang.String THREAD_FULL_EVENT
See Also:
Constant Field Values
Constructor Detail

ThreadPool

public ThreadPool()

ThreadPool

public ThreadPool(java.lang.String name)
Method Detail

getCurrent

public static ThreadPool getCurrent()

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.


setIdleMin

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


getIdleMin

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


getIdleMax

public int getIdleMax()
Returns the thread idle max.


setIdleMax

public void setIdleMax(int idleMax)
Returns the thread idle max.


setIdleTimeout

public void setIdleTimeout(long timeout)
Sets the idle timeout


getIdleTimeout

public long getIdleTimeout()
Returns the idle timeout.


setPriorityIdleMin

public void setPriorityIdleMin(int priority)
Sets the minimum number of free threads reserved for priority tasks.


getPriorityIdleMin

public int getPriorityIdleMin()

setThrottlePeriod

public void setThrottlePeriod(long period)
Sets the throttle period.


setThrottleLimit

public void setThrottleLimit(int limit)
Sets the throttle limit.


setThrottleSleepTime

public void setThrottleSleepTime(long period)
Sets the throttle sleep time.


setExecutorTaskMax

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


getExecutorTaskMax

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


getThreadCount

public int getThreadCount()
Returns the total thread count.


getThreadActiveCount

public int getThreadActiveCount()
Returns the active thread count.


getThreadStartingCount

public int getThreadStartingCount()
Returns the starting thread count.


getThreadIdleCount

public int getThreadIdleCount()
Returns the idle thread count.


getPriorityIdleCount

public int getPriorityIdleCount()
Returns the priority idle thread count.


getThreadWaitCount

public int getThreadWaitCount()
Returns the waiting thread count.


getFreeThreadCount

public int getFreeThreadCount()
Returns the free thread count.


getThreadCreateCountTotal

public long getThreadCreateCountTotal()
Returns the total created thread count.


getThreadOverflowCountTotal

public long getThreadOverflowCountTotal()
Returns the total created overflow thread count.


getThreadPriorityQueueSize

public int getThreadPriorityQueueSize()
Returns priority queue size


getThreadTaskQueueSize

public int getThreadTaskQueueSize()
Returns task queue size


getRing

public ThreadRing getRing()

start

public void start()

schedule

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


schedule

public boolean schedule(java.lang.Runnable task,
                        java.lang.ClassLoader loader)
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.


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.


interrupt

public void interrupt()
interrupts all the idle threads.


close

public void close()
Checks if the launcher should start another thread.


toString

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