Reach for a queue when the order things arrive in is the order they must be handled. In practice that shows up as four signals. Spot one, and a queue is almost always part of the answer.
Print jobs, requests to a web server, orders in a shop, messages between two programs: each must be handled fairly, oldest first. A queue also absorbs bursts — when work arrives faster than it can be done, it waits in line instead of being lost or reordered.
Free account
Sign up to read the rest of this lesson: 6 more sections, 3 drawings, 2 dry-run simulators and code in JavaScript, Python, Java and C++.
Still to come