[concurrency-interest] Real Time Java

David Holmes dholmes@dltech.com.au
Sun, 14 Sep 2003 20:58:15 +1000


Luís Eduardo V. Matta wrote:

> I would like to know how this API relates RTJ (Real Time Java):
>  - do they complement each other?
>  - are they compatible?
>  - where should I use each one?

The two API's are largely orthogonal and so, to some extent,
complement each other. But not everything between them is compatible
in that certain parts of JSR-166 wouldn't make sense in a real-time
environment. The lock implementations provided in JSR-166 are based
mostly on performance considerations, not on scheduling
predictability, or priority inversion avoidance - you probably don't
want a "fair" anything in a real-time environment. Of course, you
could define RTSJ compatible implementations of things like
ReentrantLock, but it wouldn't be trivial to deal with priority
inversion issues.

Utilities like the Atomic classes can be useful in real-time
environment just to avoid the priority inversion problems of using
locks. Lock free and wait-free algorithms can also be of benefit for
the same reason.

Thread pools aka executors are still useful in RT environments, but
some of the details of policies might be different in such an
environment.

There is some overlap in things like scheduled tasks: JSR-166 has
scheduledExecutor while RTSJ supports periodic threads. But in each
case these were designed for an environment where the other did not
exist.


You are not likely to see a VM that supports both in the near future -
just my opinion, of course.

David Holmes