Katkat

Design a thread-safe bounded queue

DatabricksSoftware Engineer · HR Screen

Last 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.