|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectnet.sourceforge.java.util.threads.ThreadPool
Simple ThreadPool implementation
| Field Summary | |
private int |
activeThreadCount
The number of currently active Threads |
private Map |
activeThreads
Maps Runnables to the Threads they
are running in.
|
private static int |
DEFAULT_POOL_SIZE
The default size to use for ThreadPool instances.
|
private int |
size
The maximum number of Threads in the ThreaPool.
|
| Constructor Summary | |
ThreadPool()
Creates a new ThreadPool with the default size.
|
|
ThreadPool(int size)
Creates a new ThreadPool with the specified
size:
|
|
| Method Summary | |
Thread |
getThread(Runnable runnable)
Gets a new Thread that runs the specified
Runnable from this ThreadPool. |
boolean |
isFreeThreadAvailable()
Returns true if a free Thread is currently
available in this ThreadPool.
|
void |
shutdown()
Performs a safe shutdown of all currently running Threads
in this ThreadPool.
|
void |
threadFinished(Runnable runnable)
Notifies this ThreadPool that the specified
Runnable has finished its work. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private static final int DEFAULT_POOL_SIZE
The default size to use for ThreadPool instances.
private int activeThreadCount
The number of currently active Threads
private int size
The maximum number of Threads in the ThreaPool.
private Map activeThreads
Maps Runnables to the Threads they
are running in.
| Constructor Detail |
public ThreadPool()
Creates a new ThreadPool with the default size.
ThreadPool(int),
DEFAULT_POOL_SIZEpublic ThreadPool(int size)
Creates a new ThreadPool with the specified
size:
size - the size to use for the ThreadPool instanceThreadPool()| Method Detail |
public Thread getThread(Runnable runnable)
Gets a new Thread that runs the specified
Runnable from this ThreadPool.
runnable - the Runnable to run in the
created Thread
Threadpublic boolean isFreeThreadAvailable()
Returns true if a free Thread is currently
available in this ThreadPool.
true if a free Thread is currently
available in this ThreadPool; false
otherwisepublic void threadFinished(Runnable runnable)
Notifies this ThreadPool that the specified
Runnable has finished its work. This means that
the Thread it was running in is freed.
runnable - the Runnable that finished its workpublic void shutdown()
Performs a safe shutdown of all currently running Threads
in this ThreadPool.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||