Threads vs processes & the GIL
P32.threads-processes.01 · Audience: guest, it-ml, language-pro
"Just add threads" is the most common way to not speed up a CPU-bound Python program. This module explains why — the Global Interpreter Lock — and then makes the difference between threads and processes concrete by looking at process IDs.
ⓘ Concept: One lock, one running thread
Why it matters — If you believe threads run Python in parallel, every CPU-bound 'optimisation' you write with them will disappoint you — and you won't know why.
Ask the mentor about this module
Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.
🎓 Practice ladder
2 graded rungs · ~20 minFirst argue the choice in an interview-style prompt, then prove the thread/process distinction with real process IDs (kernel runtime).
Rung 1 — predict the winner (interview)
Loading exercise…
Rung 2 — threads share a PID; processes don't (kernel)
Loading exercise…
Once you can say why a CPU-bound loop needs processes and an I/O-bound one is
happy with threads, the rest of concurrency is mechanics — which the next module
turns into concurrent.futures.
Where next?
Later in Threads & Processes
This module unlocks