Google interview question

Explain deadlock and how to prevent it