Message Passing

Understand how message passing is done between threads in D.

We'll cover the following

Message passing in D

send() sends messages and receiveOnly() waits for a message of a particular type. There are also prioritySend(), receive(), and receiveTimeout(), which will be explained later.

The owner in the following program sends its worker a message of type int and waits for a message from the worker of type double. The threads continue sending messages back and forth until the owner sends a negative int. This is the owner thread:

Get hands-on with 1000+ tech skills courses.