com.ibm.ulc.comm
Class ThreadPool

java.lang.Object
  |
  +--com.ibm.ulc.comm.ThreadPool

public class ThreadPool
extends java.lang.Object
implements java.io.Serializable, java.lang.Runnable, IRequestProcessor

A RequestProcessor implementation based on a thread pool with worker threads.

See Also:
Serialized Form

Field Summary
protected  UnboundedBuffer fRequests
           
protected  boolean fShutdown
           
protected  java.util.Vector fThreads
           
 
Constructor Summary
ThreadPool(int threads, boolean asDaemons)
          Constructs a thread pool with the given number of worker threads.
 
Method Summary
 void addRequest(Request request)
          Adds a request.
 boolean processNextRequest(long timeout)
          Picks up a request and process it by calling doit.
 void run()
          Processes incoming requests.
 void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fRequests

protected UnboundedBuffer fRequests

fThreads

protected java.util.Vector fThreads

fShutdown

protected boolean fShutdown
Constructor Detail

ThreadPool

public ThreadPool(int threads,
                  boolean asDaemons)
Constructs a thread pool with the given number of worker threads. If the number of threads equals 0 the request are processed in the same thread as the caller.
Method Detail

addRequest

public void addRequest(Request request)
Adds a request. If there are any worker threads it is passed to a worker. Otherwise it is executed directly.
Specified by:
addRequest in interface IRequestProcessor

processNextRequest

public boolean processNextRequest(long timeout)
Picks up a request and process it by calling doit.
See Also:
Request

run

public void run()
Processes incoming requests.
Specified by:
run in interface java.lang.Runnable

shutdown

public void shutdown()