Accenture interview question

Write a program for deadlock &how to resolve that