what is correspoding feature for synchronized in java?
synchronized in Java can guarantee safety of thread. What about C++ ? Thank you! ybungalobill Use the following in C++11: mutex _mutex; void f() { unique_lock<mutex> lock(_mutex); // access your resource here. } Use boost if you don't have a C++11 compiler yet. Akira Despite this question has been already answered, by the idea of this article I made my version of synchronized keyword using just standard library (C++11) objects: #include <mutex> #define synchronized(m) \ for(std::unique_lock<std::recursive_mutex> lk(m); lk; lk.unlock()) You can test it like: #include <iostream> #include