Design a Bounded Blocking Queue
Medium · Low-Level Design · about 40 minutes
Design a thread-safe bounded blocking queue for many producers and consumers. put(item) blocks while the queue is full; take() blocks while it is empty; items come out in FIFO order. Add close(): after it, puts fail and takes drain what's left and then return a "closed" signal instead of blocking.