|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.util.ThreadPool
public class ThreadPool
uses a pool of threads to execute tasks asynchronously and concurrently.
ThreadPool was implemented before JDK1.5 and is somewhat simillar to
ThreadPoolExecutor
ThreadWorker| Constructor Summary | |
|---|---|
ThreadPool(int numberOfThreads)
|
|
ThreadPool(int numberOfThreads,
boolean asDaemon)
|
|
| Method Summary | |
|---|---|
void |
addListener(ThreadWorker.Listener listener)
|
int |
addThread()
adds one ThreadWorker to the pool and returns the current number of threads |
void |
execute(Runnable task)
calls runTask(task); this method enables usability with jdk1.5 |
void |
finishAll(boolean now)
removes all ThreadWorkers, which will all end either after the current or the last queued task - depending on the 'now' parameter. |
ThreadWorker.Listener[] |
getListeners()
|
int |
getNumberOfThreads()
returns the number of all threads currently in this pool |
int |
getQueueSize()
total queue size over all threads |
int |
idleThreads()
returns the number of threads that are currently idle |
boolean |
isActive()
returns true if at least one thread in the pool is currently active |
boolean |
removeIdleThread()
attempts to remove a single ThreadWorker from the pool. |
int |
removeIdleThreads()
removes all threads that are currently idle. |
void |
removeListener(ThreadWorker.Listener listener)
|
void |
runTask(Runnable task)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ThreadPool(int numberOfThreads)
public ThreadPool(int numberOfThreads,
boolean asDaemon)
| Method Detail |
|---|
public boolean isActive()
public int getNumberOfThreads()
public int addThread()
public int idleThreads()
public int removeIdleThreads()
public boolean removeIdleThread()
public void finishAll(boolean now)
public int getQueueSize()
public void addListener(ThreadWorker.Listener listener)
public ThreadWorker.Listener[] getListeners()
public void removeListener(ThreadWorker.Listener listener)
public void execute(Runnable task)
runTask(task); this method enables usability with jdk1.5
execute in interface Executor
public void runTask(Runnable task)
throws IllegalStateException
IllegalStateException
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||