Actors are independent isolated active objects, which mutually share no data and communicate solely by messages passing.
Avoiding shared mutable state relieves developers from many typical concurrency problems, like live-locks or race conditions.
The body (code) of each actor gets executed by a random thread from a thread pool and so actors can proceed concurrently and independently.
Since Actors can share a relatively small thread pool, they avoid the threading limitations of the JVM and don't require
excessive system resources even in cases when your application consists of thousands of actors.
Actors typically perform three basic types of operations on top of their usual tasks:
- Create a new actor
- Send a message to another actor
- Receive a message
Actors can be created as subclasses of an particular actor class or using a factory method supplying the actor's body as a closure parameter.
There are various ways to send a message, either using the >> operator or any of the send()
Receiving a message can be performed either in a blocking or a non-blocking way, when the physical thread is returned to the pool until a message is available.
Actors can be orchestrated into various sorts of algorithms, potentially leveraging architectural patterns similar to those known from the enterprise messaging systems.