org.egothor.util.thread
Class Pool

java.lang.Object
  extended by org.egothor.util.thread.Pool
Direct Known Subclasses:
PoolFIFO, PoolLIFO

public class Pool
extends java.lang.Object

Pool creates a Stack and fills it with threads. The threads in a Pool are activated when data comes for processing.

Author:
Leo Galambos

Nested Class Summary
static interface Pool.Queue
          This class is part of the Egothor Project
 
Field Summary
protected  Pool.Queue queue
          Description of the Field
 
Constructor Summary
protected Pool(int threads)
           
 
Method Summary
 void handle(java.lang.Object data)
          Description of the Method
protected  void initialize(Pool.Queue queue)
           
 boolean process(java.lang.Object data)
          Description of the Method
 int size()
          Return the maximum number of threads in the pool.
 void stop()
          Kill all waiting threads.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queue

protected Pool.Queue queue
Description of the Field

Constructor Detail

Pool

protected Pool(int threads)
Parameters:
threads - maximum number of worker threads
Method Detail

size

public int size()
Return the maximum number of threads in the pool.

Returns:
the maximum number of threads

process

public boolean process(java.lang.Object data)
Description of the Method

Parameters:
data - Description of the Parameter
Returns:
Description of the Return Value

stop

public void stop()
Kill all waiting threads. If a thread is working it will not be killed until it has completed its task.


handle

public void handle(java.lang.Object data)
Description of the Method

Parameters:
data - Description of the Parameter

initialize

protected void initialize(Pool.Queue queue)
Parameters:
queue - queue used in this pool