Hacker News new | ask | show | jobs
by thaumasiotes 3204 days ago
> And it's still a useful exercise for exactly why you need a thread-safe blocking queue

Is it? A thread-safe blocking queue sounds like one of those take-a-number systems you find in some shops. But it would be very common to instead rely on the standard waiting-customer algorithm, in which, after waiting for some period of time, the customer gets frustrated and rings the bell at the counter. Take-a-number systems are vanishingly rare by comparison. Why do you need the queue?

1 comments

Nobody has to take a number for a queue to form. Imagine people camping in front of apple stores for the new iPhone. Nobody is taking numbers yet the first to arrive also is the first customer that gets an iPhone.

I don't know why I picked such a complicated example.

Did you ever go to the grocery store and had to wait for the people in front of you? That's also queue and yet nobody is taking numbers.

I may just be misunderstanding, but if you were to represent a queue of people waiting in line as a data structure, wouldn't they each have a number, like their index in an array, etc? How is that different than a take-a-number system?

Queues are inherently ordered, right? The take-a-number system is still a queue, it just replaces physical ordering with a paper that shows your place in line.