- All Superinterfaces:
TimerRef
- All Known Implementing Classes:
AgentTimer
Internal context that binds a
Timer to a Schedule.
A TimerContext can be used by a Timer to check its status,
to reschedule itself, and to cancel itself. TimerContext is thread
safe.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleancancel()Cancels the timer to prevent it from executing.booleanReturnstrueif the timer is currently scheduled to execute.voidreschedule(long millis) Schedules the timer to execute aftermillismilliseconds has elapsed.schedule()Returns theScheduleto which the timer is bound.
-
Method Details
-
schedule
Schedule schedule()Returns theScheduleto which the timer is bound. -
isScheduled
boolean isScheduled()Returnstrueif the timer is currently scheduled to execute.- Specified by:
isScheduledin interfaceTimerRef
-
reschedule
void reschedule(long millis) Schedules the timer to execute aftermillismilliseconds has elapsed. If the timer is currently scheduled, it will not ececute at its previously scheduled time; it will only execute at the newly scheduled time.- Specified by:
reschedulein interfaceTimerRef- Throws:
TimerException- ifmillisis negative.
-
cancel
boolean cancel()Cancels the timer to prevent it from executing. Returnstrueif this operation caused the cancellation of the timer; returnsfalseif the timer was not scheduled to execute.
-