Preparing your design workspace

Loading the problem and your saved attempt…

Design a Concurrent Multi-Producer Multi-Consumer Queue

Model a bounded FIFO queue with safe concurrent producers, consumers, blocking, closure, and testable ownership.

For this exercise, assume an in-process bounded FIFO queue accepts values from many producer threads and supplies them to many consumer threads. Producers may wait while full, consumers may wait while empty, operations support a deadline, and close rejects new values while allowing already-enqueued values to drain.

No item may be returned twice or lost after a successful enqueue, waiting operations must be awakened on relevant state changes, and callbacks never execute under the queue's internal lock. Design objects, synchronization ownership, interfaces, interaction flows, and a deterministic concurrency-test strategy.

Exclude durable storage and distributed coordination.