|
Jumpi v1.2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A Timer manages one-shot or periodic timers on behalf of TimerListeners. A
TimerListener can register its request for interruption at some time in the
future with the interruptAt, interruptPeriodically or interruptAfterDelay
calls. The TimerListener.handleTimerInterrupt()
is called after the
timer interval has expired for each TimerListener. Calling this function
is termed 'interruption' below, and is unrelated to Thread.interrupt().
A TimerListener can register multiple timers. Each call to register a timer
will return a reference to the internal timer. A timer which has not
expired can be cancelled by calling cancel(java.lang.Object)
, giving the timer
reference.
TimerListener
Method Summary | |
void |
cancel(java.lang.Object timer)
Cancel a timer which was returned from interruptAt, interruptAfterDelay, or interruptPeriodically Due to multithreading scheduling reality, it is not guaranteed that the TimerListener is not interrupted when cancel is called. |
java.lang.Object |
interruptAfterDelay(long millisecondsToDelay,
TimerListener listener)
Interrupt the provided TimerListener, once only, after approximately the time interval provided has expired. |
java.lang.Object |
interruptAt(long time,
TimerListener listener)
Interrupt the provided TimerListener, once only, at approximately the absolute time provided. |
java.lang.Object |
interruptPeriodically(long period,
TimerListener listener,
boolean startNow)
Interrupt the provided TimerListener, periodically, each time after approximately the time interval provided has expired. |
Methods inherited from interface org.jumpi.spi.Configurable |
configure, getName |
Methods inherited from interface org.jumpi.spi.Manageable |
manage |
Method Detail |
public java.lang.Object interruptAt(long time, TimerListener listener)
time
- absolute time to interrupt the TimerListenerlistener
- the TimerListener.
cancel(java.lang.Object)
,
TimerListener.handleTimerInterrupt()
public java.lang.Object interruptAfterDelay(long millisecondsToDelay, TimerListener listener)
millisecondsToDelay
- milliseconds to pass before interrupting the
TimerListener.listener
- the TimerListener.
cancel(java.lang.Object)
,
TimerListener.handleTimerInterrupt()
public java.lang.Object interruptPeriodically(long period, TimerListener listener, boolean startNow)
period
- the period in milliseconds between each interruption.listener
- the TimerListener.startNow
- whether to interrupt immediately or only after the
period.
cancel(java.lang.Object)
,
TimerListener.handleTimerInterrupt()
public void cancel(java.lang.Object timer)
Cancel a timer which was returned from interruptAt, interruptAfterDelay, or interruptPeriodically
Due to multithreading scheduling reality, it is not guaranteed that the TimerListener is not interrupted when cancel is called. This particularly when the cancellation takes place at practically the same time as the timer expiry.
timer
- The timer instance to cancel.
|
Jumpi v1.2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |