There's more...

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.72.224