O'Reilly logo

Pragmatic Scala by Venkat Subramaniam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required