What, exactly, is a deadlock?

A deadlock is a situation where two threads are waiting for each other, for whatever reasons, and the reasons of both threads depend on each other. The following figure will explain what deadlock means:

Clearly, both threads (people with guns) need the other thread's resource in order to proceed. So, nobody proceeds.

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.