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.

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: