6.8 Thread Prioritisation Levels

The Reaction framework is designed so that the main reactor thread provides low latency processing of the various different event types. For this reason the main thread is set up using the maximum thread priority level (Thread.MAX_PRIORITY). The worker threads which are responsible for executing threadable objects should run at a lower priority so that they do not interfere with the low latency operation of the main thread. For this reason, the worker threads are assigned the normal thread priority level (Thread.NORM_PRIORITY).

Thread prioritisation works correctly on most JVM implementations, but unfortunately there are some JVM's in common use which do not respect the thread priority settings. This is a particular problem when using Java under Linux. Generally speaking, JVM's which do not support thread prioritisation will still use some form of timeslicing scheduler which obviates the need to explicitly yield from executing threadable tasks. However, the timeliness of reactor event processing will degrade as the number of computationally intensive threads increases.

As a general rule, applications which only make use of threadable objects to manage blocking I/O will work correctly regardless of thread priority support. Applications which also make use of threadable objects for running computationally intensive tasks should be restricted to platforms which correctly implement the prioritised threading model in order to guarantee timely handling of reactor events.