Avoid deadlocks in a multithreaded process

deadlock, idioms, multithreading

Solution

Please see What are common reasons for deadlocks?

Problem

What are the best practices/idioms should someone follow in order to avoid deadlocks?

Original source

Related problems