Expecting Different Types of Messages

Let’s discuss how threads can handle different types of messages.

receive()

receiveOnly() can expect only one type of message. receive(), on the other hand, can wait for more than one type of message. It dispatches messages to message handling delegates. When a message arrives, it is compared to the message type of each delegate. The delegate that matches the type of the particular message handles it. For example, the following receive() call specifies two message handlers that handle messages of types int and string, respectively:

Get hands-on with 1200+ tech skills courses.