|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.jas.util.ThreadPool
public class ThreadPool
Thread pool using stack / list workpile.
Field Summary | |
---|---|
protected int |
idleworkers
Number of idle workers. |
protected java.util.LinkedList<java.lang.Runnable> |
jobstack
Work queue / stack. |
protected boolean |
shutdown
Shutdown request. |
protected StrategyEnumeration |
strategy
|
protected edu.jas.util.PoolThread[] |
workers
Array of workers. |
Constructor Summary | |
---|---|
ThreadPool()
Constructs a new ThreadPool with strategy StrategyEnumeration.FIFO and size DEFAULT_SIZE. |
|
ThreadPool(int size)
Constructs a new ThreadPool with strategy StrategyEnumeration.FIFO. |
|
ThreadPool(StrategyEnumeration strategy)
Constructs a new ThreadPool with size DEFAULT_SIZE. |
|
ThreadPool(StrategyEnumeration strategy,
int size)
Constructs a new ThreadPool. |
Method Summary | |
---|---|
void |
addJob(java.lang.Runnable job)
adds a job to the workpile. |
int |
cancel()
Cancels the threads. |
protected java.lang.Runnable |
getJob()
get a job for processing. |
int |
getNumber()
number of worker threads. |
StrategyEnumeration |
getStrategy()
get used strategy. |
boolean |
hasJobs()
check if there are jobs for processing. |
boolean |
hasJobs(int n)
check if there are more than n jobs for processing. |
void |
init()
thread initialization and start. |
void |
terminate()
Terminates the threads. |
java.lang.String |
toString()
toString. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected edu.jas.util.PoolThread[] workers
protected int idleworkers
protected volatile boolean shutdown
protected java.util.LinkedList<java.lang.Runnable> jobstack
protected StrategyEnumeration strategy
Constructor Detail |
---|
public ThreadPool()
public ThreadPool(StrategyEnumeration strategy)
strategy
- for job processing.public ThreadPool(int size)
size
- of the pool.public ThreadPool(StrategyEnumeration strategy, int size)
strategy
- for job processing.size
- of the pool.Method Detail |
---|
public void init()
public java.lang.String toString()
toString
in class java.lang.Object
public int getNumber()
public StrategyEnumeration getStrategy()
public void terminate()
public int cancel()
public void addJob(java.lang.Runnable job)
job
- protected java.lang.Runnable getJob() throws java.lang.InterruptedException
java.lang.InterruptedException
public boolean hasJobs()
public boolean hasJobs(int n)
n
- Integer
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |