Bounded versus unbounded
A pool work queue can be bounded or unbounded. An unbounded queue never rejects, but it can hide overload until memory runs out. A bounded queue applies backpressure by refusing work once full.
Rejection policies
When a bounded queue is full and the pool is at maximum threads, the executor must decide what to do with a new task:
- Abort throws an error to the submitter.
- Caller runs executes the task on the submitting thread, slowing the producer.
- Discard silently drops the newest task.
- Discard oldest drops the head of the queue to make room.
The caller runs policy is a quiet form of backpressure: it forces the producer to feel the cost of overload.
Choosing a policy
Pick abort when losing work is unacceptable and you want to surface the failure. Pick caller runs when you would rather throttle the producer than drop requests. Discard policies suit telemetry where stale data is worthless.
Key idea
A bounded queue plus a rejection policy is how a pool says enough, turning overload into a visible, controllable signal.