Dealing with Sharing -- Rainer Grimm
If you don’t share, no data races can happen. Not sharing means that your thread works on local variables. This can be achieved by copying the value, using thread-specific storage, or transferring the result of a thread to its associated future via a protected data channel.
Dealing with Sharing
by Rainer Grimm
From the article:
The patterns in this section are quite obvious, but I will present them with a short explanation for completeness. Let me start with Copied Value. If a thread gets its arguments by copy and not by reference, there is no need to synchronize access to any data. No data races and no lifetime issues are possible.
Data Races with References
The following program creates three threads. One thread gets its argument by copy, the other by reference, and the last by...

There are many well-established patterns used in the concurrency domain. They deal with synchronization challenges such as sharing and mutation but also with concurrent architectures. Today, I will introduce and dive deeper into them in additional posts.
Nico Josuttis gave a talk recently that included an example and I wanted to explain what’s going on in this example, what the issue is, and what (if anything) is broken.
C language was defined to cover a large range of computer architectures, including many which would be considered museum relics today. It therefore takes a very conservative view of what is permitted, so that it remains possible to write C programs for those ancient systems. (Which weren’t quite so ancient at the time.)
Event-driven applications, such as GUIs or servers, often apply the architecture pattern Reactor. A Reactor can accept multiple requests simultaneously and distribute them to different handlers.
Last time I showed a couple of questions about initialization. Try them
In a previous