Leoforce interview question

Explain how deadlock happens in sql?