Package net.sf.eBus.util
Class TimerTask
- java.lang.Object
-
- java.util.TimerTask
-
- net.sf.eBus.util.TimerTask
-
- All Implemented Interfaces:
Runnable
public final class TimerTask extends TimerTask
AneBus.util.TimerTaskassociates a timer task with aTimerTaskListener. When the timer expires,TimerTaskListener.handleTimeout(TimerEvent)whereEventObject.getSource()returns the value passed to theTimerTask(TimerTaskListener, Object)constructor.In eBus v. 4.2.0,
TimerTaskListeneris marked as a@FunctionalInterface. This allows the listener to be defined using a lambda expression.If
TimerTaskListener.handleTimeout(TimerEvent)throws an exception, the exception stack trace is logged at the warning level.- Author:
- Charles Rapp
-
-
Constructor Summary
Constructors Constructor Description TimerTask(TimerTaskListener listener)Creates a newTimerTask.TimerTask(TimerTaskListener listener, Object value)Creates a newTimerTask.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancancel()Cancels this timer task.voidrun()Tells the listener that this timer has expired.-
Methods inherited from class java.util.TimerTask
scheduledExecutionTime
-
-
-
-
Constructor Detail
-
TimerTask
public TimerTask(TimerTaskListener listener)
Creates a newTimerTask. This task is sent to theTimerTaskListenerwhen the timer expires. The associated value isnull.- Parameters:
listener- Inform this listener of the timeout.- Throws:
NullPointerException- iflistenerisnull.
-
TimerTask
public TimerTask(TimerTaskListener listener, Object value)
Creates a newTimerTask. This task is sent toTimerTaskListener.handleTimeout(TimerEvent)when the timer expires. The associated value isvalue.- Parameters:
listener- Inform this listener of the timeout.value- The associated value passed to the listener. May benull.- Throws:
NullPointerException- iflistenerisnull.
-
-