Dealing with Sharing -- Rainer Grimm

temp_file_DealingwithSharing-Grimm1.pngIf 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...

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.