An atomic type can be used to safely read and write to a memory location shared between two threads.
A Bad example that is likely to cause a data race:
#include <thread>
#include <iostream>
//function will add all values including and between 'a' and 'b' to 'result'
void add(int...