Short answer: a deadlock occurs when one thread has the monitor for A and tries to get the monitor for B while another thread has the monitor for B and tries to get the monitor for A. Each will wait forever for the other to give up a lock. So one trick is to always access resources in the same order. If thread 1 tries to get A then B and thread 2 tries to get A then B they'll eventually get what they need and complete. That solution is too simplistic for some complex applications but might help in small subsystems.