A thread is an independent line of execution with its own call stack — started in one line, coordinated with join.
1 Two Call Stacks
A thread runs its own stack inside the same process, sharing the same memory.
2 target = The Job
Thread(target=func) packages a function; start() runs it on a new stack.
3 join = The Rendezvous
join() blocks the caller until that thread finishes — perfect for ordering output.
4 The GIL
CPython lets only one thread run Python bytecode at a time; threads shine while waiting on I/O.
Two workers, one room
Two Call Stacks1A thread runs its own stack inside the same process, sharing the same memory. target = The Job2Thread(target=func) packages a function; start() runs it on a new stack. join = The Rendezvous3join() blocks the caller until that thread finishes — perfect for ordering output. The GIL4CPython lets only one thread run Python bytecode at a time; threads shine while waiting on I/O. 4 building blocks make up Two workers, one room
Press Run for the timeline of a main thread that starts a worker and waits properly.
join() makes this run deterministic — without it, main and worker could interleave in any order.
mainthreading ships with Python — it starts real threads inside one process.
Memory
no variables yet — press play
Console
output appears as the program runs…
Click a term, then click its description to lock the pair.
5 conceptsTap a card to expand ?threading.Threaddrops into place
?t.start()drops into place
?t.join()drops into place
?GILdrops into place
?race conditiondrops into place
Two threads — but the joins chain them into a fully ordered run.
Your predicted output — one line per console line
Hint: join() waits for one thread to finish before the next starts — sequential joins make the output fully ordered.
01threading.Thread(target=fn) plus t.start() runs fn on a second call stack.
02t.join() waits for the worker — use it whenever output order matters.
03Without join, main and worker can interleave unpredictably run to run.
04Threads share memory; unsynchronized writes can cause race conditions.
05Because of the GIL, Python threads take turns — great for I/O, not for CPU speed-ups.