C++: Preventing multiple functions from being executed at the same time
问题 I ask this questions as all the mutex documentations I find deal with a single function and I think my case is very common. My question is whether the following code won't only prevent func1() or func2() from being executed multiple times in parallel, but whether it would also prevent func1() and func2() from being executing at the same time? #include <mutex> std::mutex my_mutex; void func1() { my_mutex.lock(); // do something ... my_mutex.unlock(); } void func2() { my_mutex.lock(); // do