Recycling RT Threads
There is no way to give a thread a different run method after it has been created. Furthermore, there is no way to restart a terminated thread. In this respect threads are somewhat like the basic java.lang immutable objects: String, Integer, Float, etc. A RealtimeThread allocator that allows an application to reuse RealtimeThread objects in immortal memory needs to contend with those two problems.
The run method in a thread or real-time thread is invoked by a wrapper method that is part of the implementation. The wrapper calls the run method, and if the run method returns, the wrapper exits the thread. It also catches all throwables so they don't attempt to run off the end of the thread's stack.
The run method in a thread ...
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.