|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgnu.cajo.utils.extra.Timer
public final class Timer
This class supports the timed execution of scheduled tasks. The class makes use of the Scheduler class, in accomplishing its functionality. This means that shared objects between regular Scheduled tasks, and these timed tasks, will not run into concurrency issues. The object accepts tasks which implement the void slice() method, using the semantics defined in the Scheduler class. Additionally an interval is provided, in milliseconds, for approximate inter-execution delay. A count can also be provided, to allow the task to be run a fixed number of times. When a count of zero is provided, the task will run forever, or until removed. Delay intervals are generally expected to be several seconds, or longer. Delays much less than one second, may not be scheduled accurately.
The class methods are properly synchronized to safely allow multi-thread, and remote access.
Note: as with the Scheduler class, this class also supports serialisation. Therefore, in order for the serialisation to succeed, each of the loaded tasks must also be serialisable.
Constructor Summary | |
---|---|
Timer(Scheduler sched)
The constructor loads the timer into the Scheduler, but does not yet start it running. |
Method Summary | |
---|---|
void |
load(java.lang.Object task,
long interval,
int count)
This method loads a task for timed execution. |
void |
remove(java.lang.Object task)
This method prematurely removes a task from the timed execution queue. |
void |
slice()
The timer task implementation itself, invoked by the scheduler. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Timer(Scheduler sched)
sched
- The scheduler to use for execution.Method Detail |
---|
public void load(java.lang.Object task, long interval, int count)
task
- The operation to be timed, it can be local, remote, or even
a proxy, when enabled.interval
- The time between execution, in millisecondscount
- The number of times to run before removal, a count of zero
indicates to run indefinitely, or until removedpublic void remove(java.lang.Object task)
task
- The task to discardpublic void slice()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |