Actors

Actors implement a message-passing concurrency model. Each actor is an independent object that sends and receives messages from/to other actors. There's no association between actors and threads. A thread can execute different actors and an actor can be executed by different threads. Actors don't have shared-state and GPars guarantees that the code of the actor will be executed, so no messages will be lost. Memory will also be synchronized each time a thread is assigned to an actor, so no explicit synchronization is needed. There are two types of actors:

  • Stateless actors: Based on the DynamicDispatchActor or the ReactiveActor classes. They have no track of what messages have arrived before.
  • Stateful actors: Based on the DefaultActor ...

Get Mastering Concurrency Programming with Java 9 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.