As reported: Rubrik, two loops (2026). SDE-2 screening round 1 (Bengaluru): a bounded queue, then a thread pool on top of it with
submit(),execute(),shutdown()andshutdownNow(); the interviewer wanted shutdown handled beyond catchingInterruptedException, and changed the requirements several times during the round. Software engineer loop (India, January 2026), system coding round 1: a bounded thread-safe queue, then a thread-pool task executor, with follow-ups on exceptions thrown by a task, timeouts, and reclaiming threads.
Part 1. Implement a thread-safe bounded queue with capacity N:
put(x)blocks while the queue is full;take()blocks while it is empty.
Part 2. Implement a thread pool that uses your queue for pending tasks:
submit(task)— queue a task and return a handle for its result;execute(task)— queue a task, no result;shutdown()— stop accepting tasks, finish the queued ones, then stop the workers;shutdownNow()— stop accepting tasks, interrupt running ones, and return the tasks that never started.
Use basic primitives (locks / condition variables, synchronized with wait/notify), not the library's executors or blocking queues.
Follow-ups
- A task throws an exception — what happens to it, to its caller, and to the worker thread?
- Support a timeout (on waiting for a result, or on queue operations).
- Reclaim threads that are idle.