1 2 3 4 5 6 7

Erlang processes


Erlang processes are essential feature of the language. It's not an OS-based processes or threads. It's kinda internal type of concurrency. Erlang processes can run on multiple OS threads as well as within the same thread.

To create a process you should use spawn function:

Proc = spawn(world, start, []).

The first parameter is module name, the second is function name, and the last parameter is process function argument list.

Return value is a process identifier. Usually you user process identifier to send messages into it. Messages are the way of communication between different Erlang processes. We will talk about Erlang messages in the next lesson.

An identifier of the current process can be obtained with self() function.

To spawn a process on some function you have to export that function, even if you spawn a process within the same module.

Now, before continue, we should learn how to send and receive messages between Erlang processes.

Rate this post:
Lesson 3
Lesson 5
Share this page:

Learning plan

What is Erlang anyway?
The most simple Erlang program to start with
How you write loops in Erlang and other functional programming languages
4. Erlang processes
What is Erlang process and how to spawn it
How to communicate between Erlang processes with messages
How to organize top-level event loop in your program
7. Records
How to define your own data types with named fields