public final class TimerTask extends TimerTask
eBus.util.TimerTask associates a timer
task with a TimerTaskListener. When the timer expires,
TimerTaskListener.handleTimeout(TimerEvent) where
EventObject.getSource() returns the value passed to
the TimerTask(TimerTaskListener, Object) constructor.
In eBus v. 4.2.0, TimerTaskListener is 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.
| Constructor and Description |
|---|
TimerTask(TimerTaskListener listener)
Creates a new
TimerTask. |
TimerTask(TimerTaskListener listener,
Object value)
Creates a new
TimerTask. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
cancel()
Cancels this timer task.
|
void |
run()
Tells the listener that this timer has expired.
|
scheduledExecutionTimepublic TimerTask(TimerTaskListener listener)
TimerTask. This task
is sent to the TimerTaskListener when the
timer expires. The associated value is null.listener - Inform this listener of the timeout.NullPointerException - if listener is null.public TimerTask(TimerTaskListener listener, Object value)
TimerTask. This task
is sent to
TimerTaskListener.handleTimeout(TimerEvent)
when the timer expires. The associated value is
value.listener - Inform this listener of the timeout.value - The associated value passed to the listener.
May be null.NullPointerException - if listener is null.Copyright © 2020. All rights reserved.