|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ws4d.java.concurrency.ThreadPool
public class ThreadPool
Implements a simple thread pool which allows dynamic creation of worker threads and automatic disposal of unused worker threads after the given period of time.
Usage example:
ThreadPool myThreadPool = new ThreadPool (3, 5000);
myThreadPool.executeOrAbort(runnable1); // essential tasks, which must be started immediately or aborted
myThreadPool.execute(runnable2); ... // common tasks, which will be started as soon as possible
myThreadPool.execute(runnableN);
myThreadPool.shutdown();
Constructor Summary | |
---|---|
ThreadPool()
The constructor of the ThreadPool class, creating a thread pool with default size and default timeout. |
|
ThreadPool(int size)
The constructor of the ThreadPool class with the default life duration of idle threads |
|
ThreadPool(int size,
long timeout)
The constructor of the ThreadPool class. |
Method Summary | |
---|---|
void |
execute(java.lang.Runnable task)
Assigns tasks to the thread pool for execution. |
boolean |
executeOrAbort(java.lang.Runnable task)
Assigns tasks to the thread pool for execution. |
void |
shutdown()
Disposes of the thread pool. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ThreadPool()
public ThreadPool(int size, long timeout)
size
- maximal number of threads in the pooltimeout
- life duration of idle thread pool workerpublic ThreadPool(int size)
size
- maximal number of threads in the poolMethod Detail |
---|
public void execute(java.lang.Runnable task)
task
- runnable which is assigned to the thread poolpublic boolean executeOrAbort(java.lang.Runnable task)
task
- runnable which is assigned to the thread pool
public void shutdown()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |