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
Constructor Summary |
ThreadPool(int threads,
boolean asDaemons)
Constructs a thread pool with the given number of worker threads. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
fRequests
protected UnboundedBuffer fRequests
fThreads
protected java.util.Vector fThreads
fShutdown
protected boolean fShutdown
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.
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.
returns false when the request has been dispatched and true when there is
no request to dispatch.
- See Also:
Request
run
public void run()
- Processes incoming requests.
- Specified by:
- run in interface java.lang.Runnable
shutdown
public void shutdown()