Our example demonstrates how to use Erlang’s receive statement to wait on multiple message operations. Combining processes and message passing with receive is a powerful feature of Erlang.
To run the program:
We receive the values "one" and then "two" as expected.
Note that the total execution time is only ~2 seconds since both the 1 and 2 second timer:sleep() calls execute concurrently in separate processes.
In Erlang, we use processes and message passing instead of goroutines and channels. The receive statement in Erlang is similar to the select statement in other languages, allowing us to wait for messages from multiple sources.