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. }
1.4m articles
1.4m replys
5 comments
57.0k users