public abstract class Timer
extends java.lang.Object
The run() method may be invoked on a thread other than the UI thread. If a developer wants to process timer events on the UI thread, they can use the Application.invokeLater/invokeAndWait() API.
Modifier and Type | Field and Description |
---|---|
private double |
period |
private long |
ptr |
private java.lang.Runnable |
runnable |
private static double |
SET_PERIOD |
private static double |
UNSET_PERIOD |
Modifier | Constructor and Description |
---|---|
protected |
Timer(java.lang.Runnable runnable)
Constructs a new timer.
|
Modifier and Type | Method and Description |
---|---|
protected abstract long |
_start(java.lang.Runnable runnable) |
protected abstract long |
_start(java.lang.Runnable runnable,
int period) |
protected abstract void |
_stop(long timer) |
static int |
getMaxPeriod()
Returns the maximum timer period supported by the native system.
|
static int |
getMinPeriod()
Returns the minimum timer period supported by the native system.
|
boolean |
isRunning()
Returns true if the timer is currently running
(convenience API: might not need it)
|
void |
start()
Start a vsync-based timer if the system supports it.
|
void |
start(int period)
Starts the timer.
|
void |
stop()
Stops the timer.
|
private static final double UNSET_PERIOD
private static final double SET_PERIOD
private final java.lang.Runnable runnable
private long ptr
private double period
protected Timer(java.lang.Runnable runnable)
protected abstract long _start(java.lang.Runnable runnable)
protected abstract long _start(java.lang.Runnable runnable, int period)
protected abstract void _stop(long timer)
public static int getMinPeriod()
public static int getMaxPeriod()
public void start(int period)
public void start()
public void stop()
public boolean isRunning()