This question was asked in an interview and the approach taken architecturally to solve this problem at high level was being judged. In Java, how can this be solved -->N threads .. n resources .. what protocol do you use to ensure no deadlocks occur?
So, can someone let me know the most optimal approach ? making all the methods synchronized can make the system deadlocked, so how to solve this problem ?