Java – real time thread synchronization with normal threads
How to synchronize a real-time thread with a normal thread in Java? For example, real time threads that calculate certain temperatures and GUI threads that must collect these numbers and display them on certain controls
The implementation of the real-time library should not matter because it should follow the specification
Solution
You need two things You want real-time threads to be prioritized and preferably driven by timers to measure (almost) regularly Then, you will need a resource that can be used to pass values This can be a simple monitor with a critical area, so the timer thread can write it, or it may - and probably better - be a FIFO so that the GUI thread can eat its value at any time
In Java, the GUI (at least in swing and similar programs) already runs a separate thread for UI interaction, so you are most concerned about setting up the measurement thread Look at runnables