public class ThreadPool
extends java.lang.Object
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 and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
void |
execute(java.lang.Runnable task)
Assigns tasks to the thread pool for execution.
|
boolean |
executeOrAbort(java.lang.Runnable task) |
boolean |
executeOrAbort(java.lang.Runnable task,
int prio)
Assigns tasks to the thread pool for execution.
|
void |
shutdown()
Disposes of the thread pool.
|
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 poolpublic void execute(java.lang.Runnable task)
task - runnable which is assigned to the thread poolpublic boolean executeOrAbort(java.lang.Runnable task)
public boolean executeOrAbort(java.lang.Runnable task,
int prio)
task - runnable which is assigned to the thread poolpublic void shutdown()