Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::recursive_mutex g_myDataMutex;
- std::string myString ;
- void SetValueSync(std::string const in_newValue)
- {
- for (int i = 0; i<10000; i++)
- {
- std::lock_guard<std::recursive_mutex> myLock(g_myDataMutex);
- myString = myString + in_newValue;
- }
- }
- int main()
- {
- std::thread t1(SetValueSync, "ABC");
- std::thread t2(SetValueSync, "___");
- t2.join();
- t1.join();
- cout<<myString;
- return 0
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement