Concurrency in Functions and Messages

Joe Armstrong <>
Fri Dec 20 20:16:59 CET 2002

On Sat, 21 Dec 2002, Inswitch Solutions - Erlang Evaluation wrote:

> When a process is in receive state (receive -> ....), I understand that concurrency is managed by a queue in Erlang when other processes send messages to it.
> I don't know how Erlang manages functions calls concurrency when
> more than one process is calling the same function.
> For example io:format(.....) called by two processes at the same time.
> Does anyone know something about this ?

Yes - each process is *entirely independent* so you can think of this
as if each process calls it's own copy of io:format (only it's not a
copy since they share code) - each process has it's own stack and heap,
and things never get mixed up.

Per (Brand) pointed out to me that there was an unfortunately
terminology problem here.

Most people think that processes are big and heavy things, whereas threads
are lightweight things.

In Erlang our processes (i.e. Erlang processes) are *incredibly* light
weight i.e. much smaller and cheaper to create than threads - and just
like OS processes they are independent. Unlike threads you do not have
to worry about two two "threads of control" bumping into each other
by calling the same function at the same time - so there are no
"synchronized methods" or locks of mutexes or critical regions or all
these other silly things that make concurrent programming difficult :-)
All synchronization and transfer of data between processes is done by
explicate message passing which makes life much easier.


More information about the erlang-questions mailing list