Caffeinated Coder
Book an appointment
Lesson 29 · Under the hood

Threads, processes and the GIL

A process is a running program with its own memory; threads are workers inside it that share that memory. Step through an eight-line program, count.py, in which two threads each add 1 to count, and watch CPython's global interpreter lock (the GIL) let only one of them run Python code at a time. See how a badly timed switch loses an update, why threads still help with waiting, and how a second process gets its own interpreter, memory and GIL so two cores can work at once.

14 min11 steps5 questionsAdvanced
Fig 29 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.