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;
More input, exceptions and threads commands
- Read a file line by line
- Read a line from the keyboard
- Handle exceptions
- Run code on another thread
- Compute a value in the background
- Time a section of code
All input, exceptions and threads commands · C++ 23 cheatsheet