12. Processes
12 Processes
12.1 Processes
Erlang is designed for massive concurrency. Erlang processes are lightweight (grow and shrink dynamically) with small memory footprint, fast to create and terminate, and the scheduling overhead is low.
12.2 Process Creation
A process is created by calling spawn
:
spawn(Module, Name, Args) -> pid() Module = Name = atom() Args = [Arg1,...,ArgN] ArgI = term()
spawn
creates a new process and returns the pid.
The new process starts executing in Module:Name(Arg1,...,ArgN)
where the arguments are the elements of the (possible empty) Args
argument list.
There exist a number of other spawn
BIFs, for example, spawn/4
for spawning a process at another node.