How to make sure thre is no deadlock

Difficulty 7
Helpful 10
Save 2
View 1368