C++ 23 · Input, exceptions and threads

Share a counter between threads

An atomic integer can be updated by several threads without a mutex.

std::atomic<int> hits{0};
++hits;

Official C++ 23 documentation

More input, exceptions and threads commands

All input, exceptions and threads commands · C++ 23 cheatsheet

Was this page helpful?