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. }
548k questions
547k answers
4 comments
86.3k users