N3N interview question

How to deal with deadlocks in the multithreaded application?