My knowledge of Java is quite basic and I need to port a C++ application to Java.
I would like to receive some assistance, hints for the following inter-thread communication problem :
Thread A reads data from serial port. When a complete message has been received, thread A needs to notify thread B that a complete message has been retrieved. Thread B performs some processing on this data.
Thread A needs constantly processing serial data, even while thread B does processing on already received data.
How did we deal with this in C++ :
Thread A places serial data in global buffer. When a complete message was retrieved, an event is sent to thread B to notify new data is available. Through the use of pointers we're able to read (by thread B) and to write (by thread A) to this commonly used buffer.
I'm interesting in :
How to deal with this in Java?
I did some research yet, but didn't find a usefull solution.
? use of events -> can thread B (in its 'run' method) be notified of this event?
? use of pipes -> how to tell thread B where he can process?
? use of wait/notify -> we need to use a commonly used object to communicate between threads A and B. Thread A can't process serial data while thread B does the processing.
You see, a lot of questions. What will be the preferred solution and why? If some code would be available, like to see the basic steps.