java.util.concurrent · java.base · since Java 1.5
ThreadPoolExecutor
public class ThreadPoolExecutor extends AbstractExecutorServiceThe configurable pool behind the factories: core/max size, keep-alive, work queue, thread factory, and rejection policy — every production pool decision in one constructor.
- Bound the queue + choose a rejection policy, or overload becomes an OOM instead of a 503
Key methods
ThreadPoolExecutor(core, max, keepAlive, unit, queue, factory, handler) | The full policy constructor. |
int getActiveCount() / long getCompletedTaskCount() | Monitoring hooks. |
CallerRunsPolicy / AbortPolicy / DiscardPolicy | Rejection handlers — CallerRuns gives natural backpressure. |