|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ThreadPool
A ThreadPool interface that allows to execute tasks using pooled threads in order to ease the thread creation overhead and additionally, to associate a callback with the thread that executes the task. Subsequently, the callback for a given thread can be asked from instances of this class. Finally, the currently executed task of a thread created by this pool can be retrieved as well. The look-up methods accept plain thread objects and will return given default values in case that the specific threads have not been created by this pool. Note that a closed pool should still execute new tasks but stop pooling threads.
Method Summary | |
---|---|
void |
close()
Close the pool i.e, stop pooling threads. |
void |
execute(DispatchTask task,
DeliverTask callback)
Execute the task in a free thread or create a new one. |
DeliverTask |
getCallback(Thread thread,
DeliverTask defaultCallback)
Look-up the callback associated with the task that the given thread is currently executing or return the default value that may be null. |
DispatchTask |
getTask(Thread thread,
DispatchTask defaultTask)
Look-up the task that the given thread is currently executing or return the default value that may be null in case that the thread has not been created by an instance of this class. |
Method Detail |
---|
void execute(DispatchTask task, DeliverTask callback)
task
- The task to executecallback
- The callback that will be associated with the executing thread
or null if none.DeliverTask getCallback(Thread thread, DeliverTask defaultCallback)
thread
- The thread that is currently executing the task for which to
return the callback. In case the thread is not created by an instance of
this class the default value will be returned.defaultCallback
- The value to return in case that the thread was not
created by an instance of this class. May be null
DispatchTask getTask(Thread thread, DispatchTask defaultTask)
thread
- The thread whose currently executed task should be returned.defaultTask
- The default value to be returned in case that the thread
was not created by this instance or doesn't currently has a task. May be
null
void close()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |