Spawning with MFAs or Funs
Spawning a function with an explicit module, function name, and argument list (called an MFA) is the proper way to ensure that our running processes will be correctly updated with new versions of the module code if it is compiled while it is being used. The dynamic code upgrade mechanism does not work with spawned funs. It works only with explicitly named MFAs. For more details, read Dynamic Code Loading.
If you don’t care about dynamic code upgrade or you are certain
that your program will never be changed in the future, use the
spawn(Fun) form of spawn. If in doubt, use
spawn(MFA).
That’s it—you can now write concurrent programs!
Next we’ll look at error recovery and see how we can write fault-tolerant concurrent ...
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