Each "thread" of execution is a lightweight process.
The Erlang view of the world is that everything is a process and that processes can interact only by exchanging messages. - Joe Armstrong
-module(actor).
...
start() ->
spawn(actor, run, []).1> c(actor).
2> Pid = actor:start().
3> Pid.
<0.80.0>From the shell:
Not a process in the OS definition.
It's an Erlang process, so it runs in the Erlang VM.
It runs in user space, not bound to the kernel, so is scheduled by the Erlang Scheduler.
And it's a lightweight process...how lightweight:
A newly spawned Erlang process uses 309 words of memory (a word is 4 or 8 bytes)
Check how much memory our process(es) are using:
And they are very quick to spawn...from Joe Armstrong:
Spawning 20,000 processes took an average of 3.0 microseconds/process of CPU time and 3.4 microseconds of elapsed (wall-clock) time.
{_,Bytes} = process_info(actor_file:start(), memory).
{memory,2720}