synchronized in Java can guarantee safety of thread. What about C++?
synchronized
Java
C++
Thank you!
Use the following in C++:
#include <mutex> std::mutex _mutex; void f() { std::unique_lock<std::mutex> lock(_mutex); // access your resource here. }
2.1m questions
2.1m answers
60 comments
57.0k users