seda.sandStorm.internal
Class ThreadPool

java.lang.Object
  extended by seda.sandStorm.internal.ThreadPool
All Implemented Interfaces:
ProfilableIF

public class ThreadPool
extends java.lang.Object
implements ProfilableIF

ThreadPool is a generic class which provides a thread pool.


Field Summary
private  AggThrottle aggThrottle
           
private  int blockTime
           
private static boolean DEBUG
           
private  int idleTimeThreshold
           
private  int maxAggregation
           
(package private)  int maxThreads
           
private  ManagerIF mgr
           
(package private)  int minThreads
           
private  java.lang.String poolname
           
private  java.lang.ThreadGroup pooltg
           
private  java.lang.Runnable runnable
           
private  StageWrapperIF stage
           
private  java.util.Vector stoppedThreads
           
private  java.util.Vector threads
           
 
Constructor Summary
ThreadPool(StageWrapperIF stage, ManagerIF mgr, java.lang.Runnable runnable)
          Create a thread pool for the given stage, manager and runnable, with the thread pool controller determining the number of threads used.
ThreadPool(StageWrapperIF stage, ManagerIF mgr, java.lang.Runnable runnable, int numThreads)
          Create a thread pool with the given name, manager, runnable, and a fixed number of threads.
ThreadPool(StageWrapperIF stage, ManagerIF mgr, java.lang.Runnable runnable, int initialThreads, int minThreads, int maxThreads, int blockTime, int idleTimeThreshold)
          Create a thread pool with the given name, manager, runnable, and thread sizing parameters.
 
Method Summary
(package private)  void addThreads(int num, boolean start)
          Add threads to this pool.
 int getAggregationTarget()
          Used by a thread to request its aggregation target from the pool.
 long getBlockTime()
          Used by a thread to determine its queue block time.
 java.lang.String getName()
           
(package private)  int numThreads()
          Return the number of threads in this pool.
 int profileSize()
          Return the size of the object being profiled.
(package private)  void removeThreads(int num)
          Remove threads from pool.
 void start()
          Start the thread pool.
 void stop()
          Stop the thread pool.
(package private)  void stopThread(java.lang.Thread t)
          Cause the given thread to stop execution.
 boolean timeToStop(long idleTime)
          Used by a thread to determine whether it should exit.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

stage

private StageWrapperIF stage

mgr

private ManagerIF mgr

poolname

private java.lang.String poolname

pooltg

private java.lang.ThreadGroup pooltg

runnable

private java.lang.Runnable runnable

threads

private java.util.Vector threads

stoppedThreads

private java.util.Vector stoppedThreads

minThreads

int minThreads

maxThreads

int maxThreads

maxAggregation

private int maxAggregation

blockTime

private int blockTime

idleTimeThreshold

private int idleTimeThreshold

aggThrottle

private AggThrottle aggThrottle
Constructor Detail

ThreadPool

public ThreadPool(StageWrapperIF stage,
                  ManagerIF mgr,
                  java.lang.Runnable runnable)
Create a thread pool for the given stage, manager and runnable, with the thread pool controller determining the number of threads used.


ThreadPool

public ThreadPool(StageWrapperIF stage,
                  ManagerIF mgr,
                  java.lang.Runnable runnable,
                  int initialThreads,
                  int minThreads,
                  int maxThreads,
                  int blockTime,
                  int idleTimeThreshold)
Create a thread pool with the given name, manager, runnable, and thread sizing parameters.


ThreadPool

public ThreadPool(StageWrapperIF stage,
                  ManagerIF mgr,
                  java.lang.Runnable runnable,
                  int numThreads)
Create a thread pool with the given name, manager, runnable, and a fixed number of threads.

Method Detail

start

public void start()
Start the thread pool.


stop

public void stop()
Stop the thread pool.


addThreads

void addThreads(int num,
                boolean start)
Add threads to this pool.


removeThreads

void removeThreads(int num)
Remove threads from pool.


stopThread

void stopThread(java.lang.Thread t)
Cause the given thread to stop execution.


numThreads

int numThreads()
Return the number of threads in this pool.


getBlockTime

public long getBlockTime()
Used by a thread to determine its queue block time.


getAggregationTarget

public int getAggregationTarget()
Used by a thread to request its aggregation target from the pool.


timeToStop

public boolean timeToStop(long idleTime)
Used by a thread to determine whether it should exit.


toString

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

getName

public java.lang.String getName()

profileSize

public int profileSize()
Description copied from interface: ProfilableIF
Return the size of the object being profiled.

Specified by:
profileSize in interface ProfilableIF