std::atomic<T> template allows thread safe writing, reading and incrementing numeric values.
Reading and writing memory from different threads leads to data races and unpredictable results.
std::atomic adds necessary barriers to make the operations thread safe.
Example of using std::atomic_int: