Multithreading and Concurrency

Lesson 19 of 20

Start real threads, tame them with join, and watch two call stacks share one interpreter step by step.

The big picture

Two workers, one room

A thread is an independent line of execution with its own call stack — started in one line, coordinated with join.

Two Call Stacks

A thread runs its own stack inside the same process, sharing the same memory.

target = The Job

Thread(target=func) packages a function; start() runs it on a new stack.

join = The Rendezvous

join() blocks the caller until that thread finishes — perfect for ordering output.

The GIL

CPython lets only one thread run Python bytecode at a time; threads shine while waiting on I/O.