java.util.concurrent · java.base · since Java 1.5

ThreadPoolExecutor

declaration
public class ThreadPoolExecutor extends AbstractExecutorService

The 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 / DiscardPolicyRejection handlers — CallerRuns gives natural backpressure.