Skip to content
Actor Model — Explained with Examples

Actor Model — Explained with Examples

DodaTech Updated Jun 15, 2026 2 min read

The actor model is a concurrent computation paradigm where actors are isolated units that communicate exclusively through asynchronous messages.

The actor model treats every entity as an actor that can: receive messages, create child actors, send messages to other actors, and change its behavior for the next message. Actors have private state — no shared memory, no locks. Erlang/Elixir and Akka (JVM) are prominent implementations. The model provides natural fault tolerance through supervision trees and “let it crash” philosophy.

Think of the actor model like an office building where each employee sits in their own office. Employees do not walk into each other’s offices and grab papers (no shared state). Instead, they send memos (messages) through the internal mail system. If an employee makes a mistake, their manager (supervisor) handles it — replace the employee or try again.

The actor model eliminates race conditions and deadlocks because there is no shared mutable state. Each actor processes messages sequentially, so internal state is always consistent.

# Elixir (Erlang VM) actor example
defmodule Counter do
  def start(initial_value) do
    spawn(fn -> loop(initial_value) end)
  end

  defp loop(count) do
    receive do
      {:increment, caller} ->
        send(caller, {:ok, count + 1})
        loop(count + 1)
      {:get, caller} ->
        send(caller, {:count, count})
        loop(count)
    end
  end
end

# Usage
counter = Counter.start(0)
send(counter, {:increment, self()})
send(counter, {:get, self()})
receive do
  {:count, val} -> IO.puts("Count: #{val}")  # Count: 1
end

The actor model scales well across distributed systems because message passing works the same locally or over the network. It is the foundation of telecom systems, chat applications, and real-time services.

CSP, Goroutine, Coroutine, Thread

CSP vs Actor Model

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro