|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.mortbay.Util.ThreadPool
A pool of threads.
Avoids the expense of thread creation by pooling threads after their run methods exit for reuse.
If the maximum pool size is reached, jobs wait for a free thread. By default there is no maximum pool size.
final ArgClass myArg = new ArgClass(...);
threadPool.run(new Runnable() { public void run() { myHandler(myArg); }} );
| Constructor Summary | |
ThreadPool()
Constructor. |
|
ThreadPool(int maxThreads)
Constructor. |
|
ThreadPool(int minThreads,
int maxThreads,
java.lang.String name,
int maxIdleTimeMs)
Constructor. |
|
ThreadPool(int maxThreads,
java.lang.String name)
Constructor. |
|
ThreadPool(int maxThreads,
java.lang.String name,
int maxIdleTimeMs)
Constructor. |
|
| Method Summary | |
int |
getMaxSize()
|
int |
getMinSize()
|
int |
getSize()
|
protected void |
handle(java.lang.Object job)
Handle a job. |
void |
run(java.lang.Object job)
Run job |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public ThreadPool()
public ThreadPool(int maxThreads)
maxThreads - Maximum number of handler threads.
public ThreadPool(int maxThreads,
java.lang.String name)
maxThreads - Maximum number of handler threads.name - Name of the thread.
public ThreadPool(int maxThreads,
java.lang.String name,
int maxIdleTimeMs)
maxThreads - Maximum number of handler threads.name - Name of the thread.maxIdleTimeMs - Idle time in milliseconds before a handler thread dies.
public ThreadPool(int minThreads,
int maxThreads,
java.lang.String name,
int maxIdleTimeMs)
minThreads - Minimum number of handler threads.maxThreads - Maximum number of handler threads.name - Name of the threadmaxIdleTimeMs - Idle time in milliseconds before a handler thread dies.| Method Detail |
public int getSize()
public int getMinSize()
public int getMaxSize()
public void run(java.lang.Object job)
throws java.lang.InterruptedException
job. - If the job is derived from Runnable, the run method
is called, otherwise it is passed as the argument to the handle
method.protected void handle(java.lang.Object job)
job -
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||