- All Known Subinterfaces:
TimerContext
- All Known Implementing Classes:
AgentTimer
public interface TimerRef
External handle to a
TimerFunction bound to a Schedule. A
TimerRef can be used to check the status of a timer, to reschedule
it, and to cancel it. TimerRef 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.
-
Method Details
-
isScheduled
boolean isScheduled()Returnstrueif the timer is currently scheduled to execute. -
reschedule
void reschedule(long millis) Schedules the timer to execute aftermillismilliseconds has elapsed. If the timer is currently scheduled, it will not execute at its previously scheduled time; it will only execute at the newly scheduled time.- 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.
-