Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public final class RealtimeThread

  1. Object
  2. RealtimeThread

A thread that runs a RealtimeTask once per period. Created and started by Realtime.start(String, RealtimeParameters, RealtimeTask).

The thread applies its scheduling, runs the task’s setup(), freezes allocation and then loops: wait for the next release, run cycle(). stop() ends the loop after the cycle in progress.

Fields

public static final int STATE_STARTING = 0getState(): created, not yet running cycles.
public static final int STATE_RUNNING = 1getState(): running cycles.
public static final int STATE_STOPPED = 2getState(): ended by stop().
public static final int STATE_FAILED = 3getState(): ended by a failure, see getFailure().

Methods

public String getName()The name given at start.
public int getState()One of the STATE_ constants.
public Throwable getFailure()What ended the task when getState() is STATE_FAILED, otherwise null.
public boolean isSchedulingApplied()true when the operating system granted real-time scheduling.
public boolean isCpuPinned()true when the thread was pinned to the CPU its parameters named.
public RealtimeStatistics getStatistics()A snapshot of the thread’s statistics, as of the last completed cycle.
public void stop()Ends the loop after the cycle in progress.
public void join(long millis) throws InterruptedExceptionWaits for the thread to exit.

Inherited methods

Field details

STATE_STARTING

public static final int STATE_STARTING = 0
getState(): created, not yet running cycles.

STATE_RUNNING

public static final int STATE_RUNNING = 1
getState(): running cycles.

STATE_STOPPED

public static final int STATE_STOPPED = 2
getState(): ended by stop().

STATE_FAILED

public static final int STATE_FAILED = 3
getState(): ended by a failure, see getFailure().

Method details

getName

public String getName()
The name given at start.

getState

public int getState()
One of the STATE_ constants.

getFailure

public Throwable getFailure()
What ended the task when getState() is STATE_FAILED, otherwise null.

isSchedulingApplied

public boolean isSchedulingApplied()
true when the operating system granted real-time scheduling. false on a platform without it, or a process without the privilege, where the task runs at normal priority.

isCpuPinned

public boolean isCpuPinned()
true when the thread was pinned to the CPU its parameters named.

getStatistics

public RealtimeStatistics getStatistics()
A snapshot of the thread’s statistics, as of the last completed cycle.

stop

public void stop()
Ends the loop after the cycle in progress. The thread then calls the task’s stopped() and exits. Returns at once; use join(long) to wait.

join

public void join(long millis) throws InterruptedException
Waits for the thread to exit.

Parameters

millis long
the longest to wait, 0 for no limit