Roc Capital interview question

How can we avoid deadlock in Java