We create a new concurrent process by calling the
spawn function. The
spawn function will get as parameter a function
Fun that the process will evaluate. The return value of the
spawn function is the created process identifier (pid).
1> Fun = fun() -> 2+2 end. #Fun<erl_eval.20.52032458> 2> Pid = spawn(Fun). <0.60.0>
You can also use
spawn/3 to start a process that will execute a specific function from a module:
spawn(Module, Function, Args).
spawn/4 similarly to start a process in a different node:
spawn(Node, Fun) or
spawn(Node, Module, Function, Args).