Data Races

This lesson gives an overview of data race problems which might occur during the implementation of concurrency in C++.

A data race is a situation in which at least two threads access a shared variable at the same time. Within that, at least one thread tries to modify the variable.

If your program has a data race, it will have undefined behavior. This means all outcomes are possible and, therefore, reasoning about the program makes no sense anymore. Let me show you a program with a data race.

Get hands-on with 1200+ tech skills courses.