1. How a thread pool grows #60
Say: core threads first, then the queue, then extra threads up to max, then reject.
- With fewer than 4 threads running, a new task gets a new core thread.
- When all 4 are busy, the task waits in the queue of 10.
- Only when the queue is full does the pool start extra threads, up to max 8.
- When max is reached too, the task is rejected: map it to a 503, or let
CallerRunsPolicyslow the producer.
The catch: an unbounded LinkedBlockingQueue, as in newFixedThreadPool, never fills, so max is ignored and overload shows up as latency and then heap. Spring's default task executor has an unbounded queue too.