Design a thread-safe bounded queue
DatabricksSoftware Engineer · HR ScreenLast updated
This question evaluates skills in concurrent programming, synchronization primitives, and designing thread-safe bounded data structures that support blocking operations with timeouts, fairness, and backpressure.
Design and implement a thread-safe bounded queue supporting multiple producers and consumers. Provide blocking enqueue/dequeue with timeouts, avoid deadlocks and starvation, and ensure fairness under contention. Discuss your locking strategy (mutexes vs. lock-free), condition/signaling mechanisms, backpressure handling when the queue is full, and how you'd test correctness and performance. Analyze time and space complexity.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.