The event loop.
One waiter covers the whole restaurant by refusing to ever stand and watch food cook.
JavaScript runs on one thread, which sounds like a misprint. One thread, and yet a Node server holds thousands of connections without strain. The resolution is in what “busy” means: most of what a server does is wait, for the database, the network, a timer, and waiting takes no effort at all.
The event loop turns that into a system. A single worker spins through a queue, runs whatever is ready, and the moment a task needs something slow, hands the waiting to the operating system and grabs the next item. Results come back as fresh tasks on a later lap. The loop never stops to watch anything finish.
- Just me, yes.1
No second waiter is coming — every table in this room is one thread’s problem.
- You were ready first.2
The queue settles every argument about who is next: whichever task became ready first.
- Yell when it’s done.3
Cooking belongs to the kitchen; the waiter’s entire job is to drop the order and walk away.
- 4
The point is not speed — it is that nobody ever stands watching a pot while someone else could be served.
- On my way back round.5
A finished dish is just a new item in the queue, collected on whichever lap comes next.
- Send help.6
One table that will not stop talking holds the whole room hostage — the loop cannot walk away mid-task.
Waiting is not work
A request that takes 200 milliseconds typically spends 199 of them waiting on something else. A thread-per-request server parks an entire thread for those 199; the event loop parks nothing. It registers “wake me when the database answers” with the operating system and serves other traffic, so one thread can have thousands of requests in flight as long as nearly all of them are waiting.
The freeze you have felt
You have met a blocked event loop: you click, and the page does not even grey out — the spinner stops mid-spin, the cursor jams. Some script is crunching numbers on the one thread that also paints the screen, and nothing else runs until it finishes. The discipline is the same in browsers and servers: keep each turn of the loop short, and ship heavy computation to a worker thread that has nothing else to do.