|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectthread.ThreadPool
public class ThreadPool
Thread Pool using stack / list workpile.
Field Summary | |
---|---|
(package private) static int |
DEFAULT_SIZE
|
protected int |
idleworkers
|
protected java.util.LinkedList |
jobstack
|
private static Logger |
logger
|
protected StrategyEnumeration |
strategy
|
protected PoolThread[] |
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. |
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 |
terminate()
Terminates the threads. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final int DEFAULT_SIZE
protected PoolThread[] workers
protected int idleworkers
protected java.util.LinkedList jobstack
protected StrategyEnumeration strategy
private static Logger logger
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 int getNumber()
public StrategyEnumeration getStrategy()
public void terminate()
public void addJob(java.lang.Runnable job)
job
- Runnable.protected java.lang.Runnable getJob() throws java.lang.InterruptedException
java.lang.InterruptedException
public boolean hasJobs()
public boolean hasJobs(int n)
n
- number of jobs to check.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |