Thread pool
medium 70 minA few threads that live long, one queue with a limit, and a loop: take, run, repeat.
Watch lesson5:06
What each level should show
The same question is judged differently for mid, senior and staff.
Junior
Must show
- Explains reuse and the queue
- Uses a library pool and closes it
Will be probed on
- All workers busy?
- What does submit return?
Stands out
Mentions the limit before being asked.
Mid
Must show
- Writes loop, submit and shutdown without a race
- Keeps the worker alive on errors
- Sizes for computing and for waiting
Will be probed on
- Why a loop around wait?
- Wake one or all?
Stands out
Puts the closed flag and the queue under one lock and says why.
Senior
Must show
- Chooses a policy for a full queue
- Sees the pool that waits for itself
- Separates slow from quick work
Will be probed on
- Core, queue, maximum
- Lost exceptions
- Thread-locals
Stands out
Turns queue length into seconds.
Staff
Must show
- Walks through a slow dependency with numbers
- Plans pools, directions and shutdown for a service
- Knows when not to pool
Will be probed on
- Virtual threads
- Deadlines through a chain
Stands out
Measures waiting and running apart and knows what each means.
How the levels differ in the rest of the round is on junior, mid and senior answers. How concurrency questions start is on concurrency in an LLD round.