Kernel.spawn_monitor
spawn_monitor
, go back to Kernel module for more information.
Specs
Spawns the given function, monitors it and returns its PID and monitoring reference.
Typically developers do not use the spawn
functions, instead they use
abstractions such as Task
, GenServer
and Agent
, built on top of
spawn
, that spawns processes with more conveniences in terms of
introspection and debugging.
Check the Process
module for more process-related functions.
The anonymous function receives 0 arguments, and may return any value.
Inlined by the compiler.
Examples
current = self()
spawn_monitor(fn -> send(current, {self(), 1 + 2}) end)
Specs
Spawns the given module and function passing the given args, monitors it and returns its PID and monitoring reference.
Typically developers do not use the spawn
functions, instead they use
abstractions such as Task
, GenServer
and Agent
, built on top of
spawn
, that spawns processes with more conveniences in terms of
introspection and debugging.
Check the Process
module for more process-related functions.
Inlined by the compiler.
Examples
spawn_monitor(SomeModule, :function, [1, 2, 3])