Codibly Interview Question

How to solve deadlock problem in code