More information: http://www.cs.berkeley.edu/~mdw/proj/seda/

seda.sandStorm.internal
Class ThreadPool

java.lang.Object
  |
  +--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.

Author:
Matt Welsh

Field Summary
(package private)  int maxThreads
           
(package private)  int minThreads
           
 
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

minThreads

int minThreads

maxThreads

int maxThreads
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

More information: http://www.cs.berkeley.edu/~mdw/proj/seda/