Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

RTSJ scheduling is built around a Scheduler: it manages schedulable work and applies a feasibility algorithm to assess whether that work can meet the system’s constraints. The required base implementation, PriorityScheduler, uses fixed-priority preemptive scheduling. That defines how eligible work is ordered; it does not, by itself, guarantee that every deadline will be met.

What the scheduler does

The Real-Time Specification for Java (RTSJ) separates scheduling policy from the activities being scheduled. A Scheduler manages objects that implement the Schedulable contract. Those objects supply work, while scheduling, release, memory, and processing-group parameters describe how that work should run and what constraints apply.

RTSJ requires a base fixed-priority preemptive scheduler. The JSR 1 specification describes it as having 28 unique priority levels. The PriorityScheduler API identifies its default instance as that base scheduler. A particular real-time JVM may also provide an alternative scheduler implementation; its policy and guarantees depend on that implementation.

How work becomes eligible to run

Release parameters describe when a schedulable object may become ready to execute. They distinguish recurring work from work that arrives at irregular times.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Release mechanism What it describes Typical use
PeriodicParameters Work released on a regular schedule. A repeated control or sampling activity.
AperiodicParameters Work whose releases can occur at arbitrary times rather than at a regular interval. Handling an event whose arrival time is not periodic.
OneShotTimer A clock-driven asynchronous event triggered once. Triggering a handler at a specified one-time release.
PeriodicTimer A clock-driven asynchronous event triggered on a recurring schedule. Releasing a handler repeatedly according to a timer.

Timers can trigger asynchronous event handlers, which are themselves schedulable participants. The timer establishes a release; the scheduler then governs execution of the resulting eligible work.

Which objects participate in scheduling

The main schedulable objects include threads and asynchronous event handlers. They share the scheduling contract, but differ in how work is represented and in their memory constraints.

Object Role Important distinction
RealtimeThread A real-time thread whose run() method is managed by a scheduler. Extends java.lang.Thread and adds real-time services and parameters.
NoHeapRealtimeThread A real-time thread intended for activities that must avoid the garbage-collected heap. Cannot use heap objects or manipulate references to them; memory rules constrain its design.
AsyncEventHandler A schedulable handler for asynchronous events. Can perform work released by events, including timer-triggered events.
BoundAsyncEventHandler A schedulable asynchronous event handler with a bound-handler form. Its scheduling parameters and constraints are managed under the RTSJ contract.

A RealtimeThread can be associated with a scheduler and configured with scheduling, release, memory, and processing-group parameters. Changing the scheduler or parameters is subject to compatibility requirements, including additional restrictions for no-heap execution.

How priorities and preemption work

With fixed-priority preemptive scheduling, priority determines which ready activity is eligible to run ahead of lower-priority work. Oracle’s RTSJ introduction describes run-to-block behavior: when a higher-priority real-time thread becomes ready, it can preempt a lower-priority one. The base scheduler’s 28 unique levels are specified by JSR 1; the specification figure should not be read as a universal promise about timing or execution speed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This differs from ordinary Java thread priorities. Oracle’s introduction contrasts the ten priority levels available to ordinary Java threads with the stronger priority model used by RealtimeThread, and notes that ordinary priorities do not provide a temporal execution guarantee. Priority gives an ordering rule, not a deadline proof: actual timing depends on the real-time JVM, operating system, processor, configuration, and workload.

What feasibility analysis means

Feasibility analysis is the scheduler’s admission check: it evaluates whether a proposed schedulable workload or parameter change passes that implementation’s feasibility algorithm. RTSJ provides methods including addIfFeasible, addToFeasibility, and setIfFeasible for evaluating additions or changes. A successful check is meaningful under the implementation’s algorithm and assumptions; it is not a universal performance guarantee across platforms.

For example, an application might ask the scheduler to check a new periodic activity before admitting it. If the feasibility check rejects the change, the application should not treat that activity as accepted under the checked constraints. The exact analysis and constraints depend on the scheduler implementation.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Shared resources, budgets, and memory

Locks and priority inversion

When activities at different priorities share locks, a lower-priority activity holding a resource can delay higher-priority work. RTSJ’s javax.realtime package includes priority inheritance and priority-ceiling emulation controls to address priority inversion. Their presence does not establish one universal worst-case blocking bound; applications must account for the selected policy and implementation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Processing-group budgets

Processing groups let one or more schedulable objects share a cost budget per period. This provides a way to constrain a group’s processing demand rather than treating every activity as an entirely independent budget consumer. The group configuration is part of the scheduling design, not a substitute for validating deadlines.

Heap and no-heap execution

A NoHeapRealtimeThread is intended for hard-real-time activities that need to avoid pauses associated with garbage collection. Oracle describes the key restriction: such a thread cannot use the garbage-collected heap or manipulate heap references. That reduces exposure to garbage-collection pauses from other activity, but imposes strict object-reference and allocation rules. RTSJ’s predictable allocation mechanisms include scoped memory and immortal memory. Memory placement and parameter compatibility therefore affect whether a schedulable object can be configured as intended.

How to reason about an RTSJ scheduling design

Before relying on a scheduling arrangement, identify the choices that determine its behavior:

  • Policy: whether the implementation uses the required fixed-priority preemptive PriorityScheduler or a vendor-specific alternative.
  • Release model: whether the demand is periodic, aperiodic, or initiated through one-shot or periodic timers.
  • Execution object: whether work runs in a RealtimeThread, a NoHeapRealtimeThread, or an asynchronous handler.
  • Admission discipline: whether feasibility checks are performed before adding schedulable work or changing parameters.
  • Memory behavior: whether heap access is acceptable or scoped/immortal memory and no-heap restrictions are needed.
  • Resource sharing: how processing-group budgets and synchronization policies affect competing activities.

RTSJ defines scheduling semantics and constraints, but it does not supply a universal latency, throughput, or deadline-miss figure. Those outcomes require evidence for the specific JVM, operating system, processor, configuration, and workload.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.