Periodic Threads with Handlers

Periodic threads without async event handlers for overruns and missed deadlines are operating with incomplete information or control. Without handlers, the RTSJ runtime just returns false from waitForNextPeriod and makes the thread ready to schedule again. With async event handlers, the scheduler starts the appropriate event handler and does not run the periodic thread again until it is instructed to do so, as shown in Example 12-10.

Example 12-11 is a simple example of an overrun handler. It is invoked when the scheduler detects that a thread has overrun the time it reserved. This handler is totally permissive about the overrun. It does not try to figure out why the thread used too much processor time. It just ...

Get Real-Time Java™ Platform Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.