Last Updated: May 22, 2026
When two threads touch the same data at the same time, they can step on each other in ways that produce nonsense values, silently lose updates, or cause your program to hang. Python's threading module ships a small toolkit for keeping threads out of each other's way: Lock, RLock, Semaphore, Event, Condition, and Barrier. This lesson walks through what each of those primitives is for, how to use them, and how to avoid deadlocks.