Shared Data
To make the point clear, you only need to think about synchronisation if you have shared, mutable data because shared, mutable data is prone to data races. If you have concurrent non-synchronised read and write access to data, your program has undefined behaviour.
The easiest way to visualise concurrent, unsynchronised read and write operations is to write something to std::cout
.
Let’s have a look.