|
Jacson | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.ThreadGroup de.spieleck.util.ThreadPool
Implement a thread pool for dispatching arbitrary many jobs
to a fixed number of workers. The tasks must implement
Runnable
and are provided by a TaskSource
.
Nested Class Summary | |
protected class |
ThreadPool.WorkerThread
Inner class to actually do something. |
Field Summary | |
protected int |
critical
How many tasks are still running? |
protected java.util.Map |
eHandlers
Do we have special exception handlers? |
protected int |
runningTasks
How many tasks are still running? |
protected TaskSource |
tSource
The actual source of work |
Constructor Summary | |
ThreadPool(int size,
TaskSource tSource)
Construct a pool with a choosable number of threads. |
|
ThreadPool(TaskSource tSource)
Construct a pool with a default number of threads. |
Method Summary | |
void |
addExceptionHandler(java.lang.Class e,
ExceptionHandler handler)
Protected attach a new Exception handler. |
protected void |
finalize()
Do something useful on finalization time |
int |
getRunningTasks()
How many tasks are still working |
protected java.lang.Runnable |
getTask()
Fetch the next assignment. |
void |
join()
Wait until all jobs are done. |
void |
uncaughtException(java.lang.Thread t,
java.lang.Throwable e)
customizable exception handling. |
void |
waitDone()
Wait until we have started doing something. |
void |
waitStart()
Wait until we have started doing something. |
Methods inherited from class java.lang.ThreadGroup |
activeCount, activeGroupCount, allowThreadSuspension, checkAccess, destroy, enumerate, enumerate, enumerate, enumerate, getMaxPriority, getName, getParent, interrupt, isDaemon, isDestroyed, list, parentOf, resume, setDaemon, setMaxPriority, stop, suspend, toString |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected int runningTasks
protected int critical
protected java.util.Map eHandlers
protected TaskSource tSource
Constructor Detail |
public ThreadPool(TaskSource tSource)
public ThreadPool(int size, TaskSource tSource)
Method Detail |
protected java.lang.Runnable getTask()
public void addExceptionHandler(java.lang.Class e, ExceptionHandler handler)
public void waitStart() throws java.lang.InterruptedException
java.lang.InterruptedException
public void waitDone() throws java.lang.InterruptedException
java.lang.InterruptedException
public void join()
public int getRunningTasks()
public void uncaughtException(java.lang.Thread t, java.lang.Throwable e)
protected void finalize() throws java.lang.Throwable
java.lang.Throwable
|
Spieleck | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |