|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.jdmk.tasks.DaemonTaskServer
public class DaemonTaskServer
This class implements a Task Server that runs in its own
thread.
Objects can submit tasks to this object, and they will be executed
in background in this object daemon thread. The submitted tasks
should not block or last too long - because it will prevent following
tasks to be executed.
When a task producer calls the
submitTask(Task)
method, the task is put inside a FIFO
list, and the Task Server Thread is waken up, if necessary.
After that, the method return.
The Task Server Thread then asynchronously takes the tasks out of the FIFO list, and invokes the run() method.
This mechanism guarantee that the Task producer will spend a minimum time invoking the tasks, and will not be blocked.
Task
,
TaskServer
Constructor Summary | |
---|---|
DaemonTaskServer()
|
Method Summary | |
---|---|
protected void |
cancel(Task task)
Cancel the given task. |
protected void |
execute(Task task)
Execute the given task. |
void |
reset()
Reset the DaemonTaskServer. |
void |
start()
Start the Task Server Thread. |
void |
start(int threadPriority)
Start the Task Server Thread. |
void |
stop()
Stop the Task Server Thread. |
void |
submitTask(Task task)
Submit a task. |
void |
terminate()
Stop the Task Server Thread. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DaemonTaskServer()
Method Detail |
---|
protected void execute(Task task) throws InterruptedException
task.run()
. It is provided
as a customization hook for subclasses.
task
- The task to execute.
InterruptedException
- if the task is interrupted.protected void cancel(Task task) throws InterruptedException
task.cancel()
.
It is provided as a customization hook for subclasses.
task
- The task to cancel.
InterruptedException
- if cancel is interrupted.public void submitTask(Task task)
submitTask
in interface TaskServer
task
- The Task to execute.public void stop() throws InterruptedException
InterruptedException
- if stop is interrupted.public void terminate() throws InterruptedException
submitTask()
.
When terminated, the object can not be started again, unless
reset()
is called.
InterruptedException
- if cancel is interrupted.public void reset()
terminate()
IllegalStateException
- if the DaemonTaskServer is running.public void start()
IllegalStateException
- if the DaemonTaskServer is terminated.public void start(int threadPriority)
threadPriority
- Priority of the daemon thread see
Thread
.
IllegalStateException
- if the DaemonTaskServer is terminated.
|
Open Source build 02 opendmk-1.0-b02 2007.10.01_19:17:46_MEST |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |