Actors and Threads
The previous example gave a good idea of what’s going on with actors, but it also raises a question. In the previous output we see that the two messages sent to depp were both processed by the same thread whereas the two messages sent to hanks were both processed by one other thread. This may give an impression that actors hold on to their threads, but that’s not true—in fact, on your machine you may even notice the actors switch threads.
Threads are to actors like service agents are to customers. When you call a customer service line, any available agent answers. If you drop the call and redial, the previous agent has moved on to another call and a totally random dude now answers. Only in an extreme coincidence would you ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access