In Java, message passing is when a message is sent from one thread to another. Threads do not have shared memory so they won’t share semaphores or monitors and can’t use shared variables to communicate. But threads can be used for communication and synchronization
Send operation sends messages via a channel and messages are received from receive operation through a channel. We can pass messages synchronously which means that a sender blocks until the receiver does a receive and vice versa. Since the sender and receiver are at specific known points in their code at a known specific instant of time, synchronous message passing is also called a simple rendezvous with a one-way flow of information from the sender to the receiver. We can take the example of a chess game agent where agents can process messages synchronously
When it is about the asynchronous message passing, the sender does not block. The message is queued or buffered in the situation when there is no receiver to receive a message. If there is no queued or buffered message when a receive is executed, the receiver still blocks.