LESSON 1.C1 · 5 STAGES · 2 CONTROLS · 3 CHECKSPRO · PREVIEW
Python concurrency — threads vs processes vs asyncio
Watch 8 tasks run four ways on one timeline, and see which finishes first.
Pro lesson. Stage 1 is free to watch. Pro opens all 5 stages, 2 controls and 3 checks, in this lesson and every other.
Go Pro · $8.25/moEXPLAINER · 1.C1 · CONCURRENCY BAYONE AFTER ANOTHER · 435 MS · 1.0× · MAX 1 CORE
01
Stage 1 of 5 · Baseline
One thread runs the tasks in turn. While an I/O-bound task waits, the CPU sits idle.
Explain it simply
Eight tasks wait to run. The I/O-bound ones mostly wait, like a download. The CPU-bound ones only compute. One thread runs them in order. Look at the strip at the top: while a task waits, it drops to zero. The CPU sits idle.
One thread runs the 8 tasks one after another. 200 ms of Python work plus 235 ms of waits end at 435 ms.
Python workI/O waitblocked by the GIL or loopprocess start, data copy, switch intervaldone
Toy: 4 cores · 8 tasks · 1 ms steps · costs measured on CPython 3.12, rounded
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
One after another, the total is all work plus all waits.
PRO LESSON · YOU WATCHED STAGE 1 OF 5
Unlock the full explainer
- 4 more stages and 2 live controls
- 2 mix-up cards and 3 predict-then-reveal checks
- Watch it as a narrated video, in three voices
- Every Pro lesson and capstone · 656 in total
$99 a year, or $15 a month. Cancel any time.