Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Consider an actor that sends a message to another actor. It is easy to implement the control flow if each actor runs in a separate thread. The sending actor places a message in the mailbox, and its thread keeps on going. The receiving actor’s thread is awakened whenever an item is placed in the mailbox.
Some programs contain so many actors that it would be expensive to create a separate thread for each of them. Could we run multiple actors in the same thread? Let’s assume that actors spend most of their time waiting for messages. Instead of having each of them block on a separate thread, we can have a single thread executing the message handling functions of multiple actors. This works, provided each message handling function only does a small amount of work before it waits for the next message.