Question d’entretien chez Barclays

how would you avoid deadlock in C++? Write the code for all solutions.