Does adding more workers always finish the job sooner? In a shop with a single till, calling in extra staff does not move the queue any faster.
Many people use "handling many things at once" and "computing many things at once" interchangeably. They are different, and confusing them leads to piling on threads and wondering why nothing got faster. Flip the toggles below and see.
Even with one core several tasks can be in progress: while one waits on IO another uses the CPU. At any single instant only one is actually computing.
With four cores, four computations physically happen together. Concurrency works on one core; parallelism requires more cores.
CPU-bound work (image processing, crypto, compression) gets no faster with more threads on one core — only more switching. IO-bound work (queries, API calls, file reads) overlaps with more threads even on one core, because waiting uses no CPU.
The panels run the same work with 1 and 4 threads. With CPU work on 1 core, four threads finish no sooner — sometimes later. Switch cores to 4 and it finally scales. Then switch the workload to IO and watch four threads win on a single core.
No more work is computed at one instant than you have cores. With four cores, a hundred threads still compute at most four things at once. So for CPU-bound work, creating far more threads than cores gains nothing and costs context switches and memory. For IO-bound work the opposite holds: threads far outnumbering cores is fine, because most of them are asleep.
Start from arithmetic. If one request spends c on CPU and w waiting, keeping one core busy needs roughly (c+w)/c requests in flight. Ten milliseconds of CPU and ninety of waiting means about ten per core. CPU-bound: near the core count. IO-bound: scaled by that ratio. This is the first calculation behind both thread pool and connection pool sizing.
Try it in the simulator
Terms in this chapter
Switching hides waiting; it cannot create computation.
The remaining problem
Which are server requests? A little parsing, a long database wait, a little response — textbook IO →