I understand the question, but these problems are related to locking and mutual exclusion.
Erlang's way of doing something through Actors avoids the lock problem. Creating producers and consumers, as well as readers and writers, is a good job at Erlang, but you will use messages instead of a shared variable to solve the mutual exclusion problem.
In Erlang, you "do not share anything."
Kekoa source share