Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (6.1k points)

Please make me understand this concept. Thank you.

1 Answer

0 votes
by (11.7k points)

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. 

Related questions

0 votes
1 answer
asked Feb 18, 2021 in Linux by rahulnayar01123 (6.1k points)
0 votes
1 answer

Browse Categories

...