Most developers say:
“Deadlock is when threads block each other.”
That’s correct — but not enough to pass a real interview.
❌ Bad answer
When threads block each other.
✅ Senior answer
A deadlock occurs when two or more threads are waiting for each other to release resources, causing all of them to be blocked indefinitely. It typically happens due to improper locking or blocking async code.
👉 All 4 must happen for a deadlock to occur.
object lock1 = new object();
object lock2 = new object();
Task.Run(() => {
lock (lock1) {
Thread.Sleep(100);
lock (lock2) { }
}
});
Task.Run(() => {
lock (lock2) {
Thread.Sleep(100);
lock (lock1) { }
}
});// ❌ Dangerous var result = SomeAsync().Result;
👉 Blocking async code like this can cause deadlocks in ASP.NET.
Want to practice explaining this like a senior?
Practice Now