spawn creates a new Erlang VM process to run a given module, function, and arguments and returns its process id pid.

defmodule Bob do
  def say(message) do
    IO.puts "[#{inspect self}] Bob says: #{message}"

iex> Bob.say "I'm Bob"
[#PID<0.57.0>] Bob says: sup

iex> spawn(Bob, :say, ["I'm Bob"])
[#PID<0.101.0>] Bob says: I'm Bob

self returns the current process’ pid

Check the PIDs that are printed. We’ve just run the Bob.say function as a separate process.

Additional reading: