Common Pitfalls with Mutex in C++ Multithreading