Synchronous message passing Synchronous message passing occurs between objects that are running at the same time. It is used by object-oriented programming languages such as
Java and
Smalltalk. Synchronous messaging is analogous to a synchronous function call; just as the function caller waits until the function completes, the sending process waits until the receiving process accepts the message. This can make synchronous communication unworkable for some applications. For example, large, distributed systems may not perform well enough to be usable. Such large, distributed systems may need to operate while some of their subsystems are down for maintenance, etc. Imagine a busy business office having 100 desktop computers that send emails to each other using synchronous message passing exclusively. One worker turning off their computer can cause the other 99 computers to freeze until the worker turns their computer back on to process a single email.
Asynchronous message passing Message passing systems can be broadly categorized based on how send and receive operations interact with executing processes. In
synchronous message passing, the sending process may block until the receiver has accepted the message, ensuring tight coordination. In
asynchronous models, the sender continues execution after sending a message, and messages are typically stored in a queue or buffer until the receiving process retrieves them. With asynchronous message passing the receiving object can be down or busy when the requesting object sends the message. Continuing the function call analogy, it is like a function call that returns immediately, without waiting for the called function to complete. Messages are sent to a queue where they are stored until the receiving process requests them. The receiving process processes its messages and sends results to a queue for pickup by the original process (or some designated next process). Asynchronous messaging requires additional capabilities for storing and retransmitting data for systems that may not run concurrently, and are generally handled by an intermediary level of software (often called
middleware); a common type being Message-oriented middleware (MOM). The buffer required in
asynchronous communication can cause problems when it is full. A decision has to be made whether to block the sender or whether to discard future messages. A blocked sender may lead to
deadlock. If messages are dropped, communication is no longer reliable.
Hybrids Synchronous communication can be built on top of asynchronous communication by using a
Synchronizer. For example, the α-Synchronizer works by ensuring that the sender always waits for an acknowledgement message from the receiver. The sender only sends the next message after the acknowledgement has been received. On the other hand, asynchronous communication can also be built on top of synchronous communication. For example, modern
microkernels generally only provide a
synchronous messaging primitive and asynchronous messaging can be implemented on top by using
helper threads. ==Distributed objects==