The Concurrency Primitives
Everything we’ve learned about sequential programming is still true for concurrent programming. All we have to do is to add the following primitives:
Pid = spawn(Mod, Func, Args)-
Creates a new concurrent process that evaluates
apply(Mod, Func, Args). The new process runs in parallel with the caller.spawnreturns aPid(short for process identifier). You can use aPidto send messages to the process. Note that the functionFuncwith aritylength(Args)must be exported from the moduleMod.When a new process is created, the latest version of the module defining the code is used.
Pid = spawn(Fun)-
Creates a new concurrent process that evaluates
Fun(). This form ofspawnalways uses the current value of the fun being ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access