Roc Capital Interview Question

How can we avoid deadlock in Java