In spite of over 40 years of shared memory parallel programming, there has been a surprising amount of confusion surrounding the basic meaning of shared variables.
C++11 both added threads to the language, and clarified the behavior of shared variables. The approach relies on a careful definition of a "data race", which is treated as an error, and a guarantee of expected behavior in the absence of such data races.
We'll quickly introduce some of the thread support features in C++11 and then describe the rules for programming with shared variables. We'll illustrate the finer points of the "data race" definition by going through a number of small examples. Much of this is also applicable to C11.