Proper implementation of thread synchronization requires a lot of attention to detail and thorough analysis. A very common problem in multithreaded applications is a deadlock. This is a situation whereby a thread is blocked because it is waiting for another thread that, in turn, is blocked because it is waiting for the first thread. As a result, two threads are blocked infinitely.
A deadlock occurs if two or more mutexes are required for synchronization. C++17 introduced std::scoped_lock, available at https://en.cppreference.com/w/cpp/thread/scoped_lock an RAII wrapper for multiple mutexes that helps to avoid deadlocks.