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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.