public abstract class Timer extends Object
To schedule a timer, simply create a subclass of it (overriding run()
)
and call schedule(int)
or scheduleRepeating(int)
.
NOTE: If you are using a timer to schedule a UI animation, use
AnimationScheduler
instead. The
browser can optimize your animation for maximum performance.
Constructor and Description |
---|
Timer() |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels this timer.
|
boolean |
isRunning()
Returns
true if the timer is running. |
abstract void |
run()
This method will be called when a timer fires.
|
void |
schedule(int delayMillis)
Schedules a timer to elapse in the future.
|
void |
scheduleRepeating(int periodMillis)
Schedules a timer that elapses repeatedly.
|
public final boolean isRunning()
true
if the timer is running. Timer is running if and only if it is scheduled
but it is not expired or cancelled.public void cancel()
public abstract void run()
public void schedule(int delayMillis)
delayMillis
- how long to wait before the timer elapses, in millisecondspublic void scheduleRepeating(int periodMillis)
periodMillis
- how long to wait before the timer elapses, in milliseconds, between each
repetitionCopyright © 2018. All rights reserved.