|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.objectwave.utility.ThreadPoolManager
A simple thread pool implementation. With only two new lines of code, you could manage all of your threads. Original Code new Thread(r).start() New code ThreadPoolManager mgr = new ThreadPoolManager(10); mgr.start(r);
Nested Class Summary | |
static class |
ThreadPoolManager.Test
Unit Tests |
Field Summary | |
protected com.objectwave.utility.RunnableQueue |
waitingRunnables
|
Constructor Summary | |
ThreadPoolManager(int numOfThread)
|
Method Summary | |
java.lang.Runnable[] |
clearQueue()
Remove all runnable objects waiting to execute. |
protected void |
finalize()
If we get garbaged collected, shutdown the thread pool. |
java.lang.ThreadGroup |
getThreadGroup()
Get the threadGroup that contains all of the threads in the thread pool. |
boolean |
isShutdown()
If the thread pool is being shutdown, this method will return true. |
java.lang.Runnable[] |
shutdown()
Gracefully terminate the ThreadPool. |
void |
start(java.lang.Runnable runnable)
Enqueue the runnable. |
protected boolean |
threadWaiting(com.objectwave.utility.ManagedThread mt)
Called by the managed thread when it is done processing a runnable. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected com.objectwave.utility.RunnableQueue waitingRunnables
Constructor Detail |
public ThreadPoolManager(int numOfThread)
numOfThread
- Method Detail |
public java.lang.ThreadGroup getThreadGroup()
public boolean isShutdown()
shutdown()
public java.lang.Runnable[] clearQueue()
public java.lang.Runnable[] shutdown()
public void start(java.lang.Runnable runnable)
runnable
- protected boolean threadWaiting(com.objectwave.utility.ManagedThread mt) throws java.lang.InterruptedException
mt
-
java.lang.InterruptedException
ManagedThread
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |