APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.glass.ui

public abstract Class Timer

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.glass.ui.gtk.GtkTimer, com.sun.glass.ui.headless.HeadlessTimer, com.sun.glass.ui.ios.IosTimer, com.sun.glass.ui.mac.MacTimer, com.sun.glass.ui.monocle.MonocleTimer, com.sun.glass.ui.win.WinTimer
Imports
java.lang.annotation.Native

A high-resolution timer. An application may either override its run() method, or pass a Runnable object to the constructor of the Timer class.

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.

Field Summary

Modifier and TypeField and Description
private double
private long
private final Runnable
private static final double
private static final double

Constructor Summary

AccessConstructor and Description
protected
Timer(Runnable runnable)

Constructs a new timer.

Method Summary

Modifier and TypeMethod and Description
protected abstract void
_pause(long timer)

protected abstract void
_resume(long timer)

protected abstract long
_start(Runnable runnable)

protected abstract long
_start(Runnable runnable, int period)

protected abstract void
_stop(long timer)

public static int
getMaxPeriod()

Returns the maximum timer period supported by the native system.

public static int
getMinPeriod()

Returns the minimum timer period supported by the native system.

public synchronized boolean
isRunning()

Returns true if the timer is currently running (convenience API: might not need it)

public synchronized void
pause()

Pauses the timer.

public synchronized void
resume()

Resumes the timer.

public synchronized void
start(int period)

Starts the timer.

public synchronized void
start()

Start a vsync-based timer if the system supports it.

public synchronized void
stop()

Stops the timer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

periodback to summary
private double period
ptrback to summary
private long ptr
runnableback to summary
private final Runnable runnable
SET_PERIODback to summary
private static final double SET_PERIOD
Annotations
@Native
UNSET_PERIODback to summary
private static final double UNSET_PERIOD
Annotations
@Native

Constructor Detail

Timerback to summary
protected Timer(Runnable runnable)

Constructs a new timer. If the application overrides the Timer.run(), it should call super.run() in order to run the runnable passed to the constructor.

Method Detail

_pauseback to summary
protected abstract void _pause(long timer)
_resumeback to summary
protected abstract void _resume(long timer)
_startback to summary
protected abstract long _start(Runnable runnable)
_startback to summary
protected abstract long _start(Runnable runnable, int period)
_stopback to summary
protected abstract void _stop(long timer)
getMaxPeriodback to summary
public static int getMaxPeriod()

Returns the maximum timer period supported by the native system.

getMinPeriodback to summary
public static int getMinPeriod()

Returns the minimum timer period supported by the native system.

isRunningback to summary
public synchronized boolean isRunning()

Returns true if the timer is currently running (convenience API: might not need it)

pauseback to summary
public synchronized void pause()

Pauses the timer. See JDK-8189926. Timer is paused only from the timer thread.

resumeback to summary
public synchronized void resume()

Resumes the timer. See JDK-8189926 Timer can get resumed from different threads.

startback to summary
public synchronized void start(int period)

Starts the timer. The period must be in the range getMinPeriod() .. getMaxPeriod(). If the timer is currently started, it gets stopped before re-starting. If starting the timer fails, the RuntimeException is thrown.

startback to summary
public synchronized void start()

Start a vsync-based timer if the system supports it. A RuntimeException is thrown if the system does not support vsync-based timer or if there was an issue starting the timer.

stopback to summary
public synchronized void stop()

Stops the timer. If a vsync-based timer is stopped, all of the vsync timers currently running will be stopped.