serversim
LearnSimulatorTemplatesPricing
…
…
Open menu
Learn↗Simulator↗Templates↗Pricing↗
My DocumentsDocs
Foundations contents/5 / 85min

Can a computer do something else while it waits?

The trapIf the counter has to stand empty while a customer fetches paperwork from the vault, how do you ever serve more of them?

Move it yourself

0/49 stepSpeedcustomers at once
0.0sdone01DBvaultqueue 0
servingon the phoneat the vaultfree

0.0s · queue 0 · serving 0 · done 0 — nobody has arrived yet

Follow the sentences

1/40

Can a computer do something else while it waits?

Text mode advances to the next sentence every 3 seconds.

Picture it this way

There is only one counter. It is the only place where work actually happens, and while a customer is away at the vault fetching paperwork, that counter stands empty.

With a single customer, that one person works through their errands in order — and every trip to the vault leaves the counter idle. The waiting from the last chapter shows up here as an empty counter.

So what if four customers are in the bank at once? While one is at the vault, another is using the counter. Nobody built a second counter; the empty time simply got used.

Switch "customers at once" between 1 and 4 above. In a computer, one of these customers is one thread.

Now the numbers

measured · computed just now

One customer working through 12 errands alone takes 96.0 ticks to finish them all (a tick here is the simulator's own clock, not a second — what matters is the ratio between the two numbers). Over that whole stretch the counter was actually working 25.0% of the time. The rest was spent waiting for paperwork to come back from the vault.

Raise it to 4 customers and the same 12 errands finish in 34.6 ticks — 2.8 times faster. The counter is still a single counter; only the share of time it spent working went up, to 69.4%. The number of people at the vault at once went from 1 to 4.

It is not free. The number of times the person at the counter changed rose from 0 to 21, and the memory held open at once went from 1 place to 4 — each customer keeps their own. Keep adding customers and this cost is what eventually sets the limit.

These numbers are not written into the sentence. They come from a simulation run while this page rendered.

Go one level deeper

Execution models, lesson 5 — Processes: the first way to share a CPU→

In one sentence

Processes and threads did not appear to work faster; they appeared so the waiting time would not be wasted.

Progress is stored in this browser only (no account, no sync between devices).

Quick check

0 / 3 correct
  1. 1.You split mostly-waiting work into several strands and run them together on a machine with a single CPU. What happens?

  2. 2.Going from 1 customer to 4, what actually increased?

  3. 3.With a single counter, what does quadrupling the customers (threads) do for work that only computes and never waits?

New words here

process
One running program. It holds its own memory, so a neighbour falling over does not take it down.
thread
One strand of work inside a program. Each customer above is one thread, carrying its own note of where it left off.
context switch
Changing who sits at the counter: write down where you were, fetch the other person's notes. It costs time.

Previous

Why is one fetch instant and another slow?

Next

Why does a busy server fall behind?

serversim

Learn why servers slow down and fail, then reproduce the same mechanism in a simulator.

© 2025-2026 serversim · Architecture simulation tool

Product

  • Learn
  • Simulator
  • Templates
  • Pricing

Resources

  • Docs
  • Benchmarks
  • Blog

Legal

  • Privacy
  • Terms
  • Refund