← Questions

Bounded blocking queue

0
AppleCodingLast asked Aug 2026

Implement a first-in, first-out queue with a fixed capacity that producer and consumer threads share. put blocks while the queue is full and take blocks while it is empty, and waiting threads must sleep rather than spin. Use a lock with condition variables (or semaphores), handle spurious wakeups, and explain why your code cannot lose a wakeup or deadlock. Follow-ups may include timeouts on put and take and shutting the queue down cleanly.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding