Class QueuedThreadPool

java.lang.Object
All Implemented Interfaces:
Executor, ThreadFactory, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle, ThreadPool, ThreadPool.SizedThreadPool, TryExecutor, VirtualThreads.Configurable
Direct Known Subclasses:
MonitoredQueuedThreadPool

A thread pool with a queue of jobs to execute.

The queue of jobs should be unbounded, because critical jobs that have been submitted for execution cannot be rejected due to the queue bound limit. The queue might be temporarily full due to a job submission spike. Furthermore, the same HTTP request may be handled by different jobs, and would be non-optimal to reject a job of a request that is already being handled in favor of a job for a new concurrent request that is not yet handled by the application.

Jetty components that need threads (such as network acceptors and selector) may lease threads from this thread pool using a ThreadPoolBudget; these threads are "active" from the point of view of the thread pool, but not available to run transient jobs such as processing an HTTP request or a WebSocket frame.

QueuedThreadPool has a ReservedThreadExecutor which leases threads from this pool, but makes them available as if they are "idle" threads.

QueuedThreadPool therefore has the following fundamental values:

  • threads: the current number of threads. These threads may execute a job (either internal or transient), or may be ready to run (either idle or reserved). This number may grow or shrink as the thread pool grows or shrinks.
  • readyThreads: the current number of threads that are ready to run transient jobs. This number may grow or shrink as the thread pool grows or shrinks.
  • leasedThreads: the number of threads that run internal jobs. This number is typically constant after this thread pool is started.

Given the definitions above, the most interesting definitions are:

Other definitions, typically less interesting because they take into account threads that execute internal jobs, or because they don't take into account available reserved threads (that are essentially ready to execute transient jobs), are: