online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> #include <mutex> #include <shared_mutex> #include <thread> using namespace std; class demo { public: void sam() { unique_lock lock(mutex_); ++b; } unsigned int get() { shared_lock lock(mutex_); return b; } private: mutable shared_mutex mutex_; unsigned int b = 0; }; int main() { demo tbh; auto sam_and_roi = [&tbh]() { for (int x = 0; x < 6; x++) { tbh.sam(); cout << this_thread::get_id() << tbh.get() << '\n'; } }; thread start(sam_and_roi); start.join(); }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue