Top Description Fields Constructors Methods
org.eclipse.jetty.util.thread

public Class ExecutorThreadPool

extends ContainerLifeCycle
implements SizedThreadPool, TryExecutor, Configurable
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.util.VirtualThreads.Configurable, org.eclipse.jetty.util.thread.TryExecutor, java.util.concurrent.Executor, org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool, org.eclipse.jetty.util.thread.ThreadPool
Annotations
@ManagedObject:A thread pool
Imports
java.io.IOException, java.util.ArrayList, .Collections, .List, java.util.concurrent.BlockingQueue, .Executor, .LinkedBlockingQueue, .ThreadPoolExecutor, .TimeUnit, java.util.stream.Collectors, org.eclipse.jetty.util.ProcessorUtils, .VirtualThreads, org.eclipse.jetty.util.annotation.ManagedAttribute, .ManagedObject, org.eclipse.jetty.util.component.ContainerLifeCycle, .Dumpable, .DumpableCollection

A org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool wrapper around ThreadPoolExecutor.

Field Summary

Modifier and TypeField and Description
private final ThreadPoolBudget
private boolean
private boolean
private final ThreadPoolExecutor
private final ThreadGroup
private int
private String
private int
private int
private TryExecutor
private Executor

Constructor Summary

AccessConstructor and Description
public
public
ExecutorThreadPool(int maxThreads)

public
ExecutorThreadPool(int maxThreads, int minThreads)

public
ExecutorThreadPool(int maxThreads, int minThreads, BlockingQueue<Runnable> queue)

public
public
ExecutorThreadPool(ThreadPoolExecutor executor, int reservedThreads)

public
ExecutorThreadPool(ThreadPoolExecutor executor, int reservedThreads, ThreadGroup group)

private
ExecutorThreadPool(ThreadPoolExecutor executor, int minThreads, int reservedThreads, ThreadGroup group)

Method Summary

Modifier and TypeMethod and Description
protected void
doStart()

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.doStart.

Starts the managed lifecycle beans in the order they were added.

protected void
doStop()

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.doStop.

Stops the managed lifecycle beans in the reverse order they were added.

public void
dump(Appendable
The appendable to dump to
out
,
String
The indent to apply after any new lines.
indent
)

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.dump.

Implements org.eclipse.jetty.util.component.Dumpable.dump.

Dump this object (and children) into an Appendable using the provided indent after any new lines.

public void
execute(Runnable
the runnable task
command
)

Overrides default org.eclipse.jetty.util.thread.TryExecutor.execute.

Implements java.util.concurrent.Executor.execute.

Executes the given command at some time in the future.

public int
public int
getIdleTimeout()

Returns: the maximum thread idle time in ms.

public int
public int
public String
getName()

Returns: the name of the this thread pool

public int
getReservedThreads()

Returns: number of reserved threads or -1 to indicate that the number is heuristically determined

public ThreadPoolBudget
public int
public int
public Executor
public boolean
isDaemon()

Returns: whether this thread pool uses daemon threads

public boolean
public boolean
public void
join()

Implements org.eclipse.jetty.util.thread.ThreadPool.join.

Blocks until the thread pool is stopped.

protected Thread
public void
setDaemon(boolean
whether this thread pool uses daemon threads
daemon
)

public void
setDetailedDump(boolean detailedDump)

public void
setIdleTimeout(int
the maximum thread idle time in ms.
idleTimeout
)

Sets the maximum thread idle time in ms.

public void
public void
public void
setName(String
the name of this thread pool, used to name threads
name
)

Set the name of this thread pool, used to name threads.

public void
setReservedThreads(int
number of reserved threads or -1 to determine the number heuristically
reservedThreads
)

Sets the number of reserved threads.

public void
setThreadsPriority(int priority)

public void
setVirtualThreadsExecutor(Executor
the Executor to use to execute tasks in virtual threads
executor
)

Overrides default org.eclipse.jetty.util.VirtualThreads.Configurable.setVirtualThreadsExecutor.

public String
toString()

Overrides org.eclipse.jetty.util.component.AbstractLifeCycle.toString.

Returns a string representation of the object.

public boolean
tryExecute(Runnable
The task to be executed
task
)

Implements org.eclipse.jetty.util.thread.TryExecutor.tryExecute.

Attempt to execute a task.

Inherited from org.eclipse.jetty.util.component.ContainerLifeCycle:
addBeanaddBeanaddEventListeneraddManagedcontainsdestroydumpdumpdumpObjectsdumpStdErrgetBeangetBeansgetBeansgetContainedBeansgetContainedBeansisAutoisManagedisUnmanagedmanageremoveBeanremoveBeansremoveEventListenersetBeansstartstopunmanageupdateBeanupdateBeanupdateBeansupdateBeans

Field Detail

_budgetback to summary
private final ThreadPoolBudget _budget
_daemonback to summary
private boolean _daemon
_detailedDumpback to summary
private boolean _detailedDump
_executorback to summary
private final ThreadPoolExecutor _executor
_groupback to summary
private final ThreadGroup _group
_minThreadsback to summary
private int _minThreads
_nameback to summary
private String _name
_priorityback to summary
private int _priority
_reservedThreadsback to summary
private int _reservedThreads
_tryExecutorback to summary
private TryExecutor _tryExecutor
_virtualThreadsExecutorback to summary
private Executor _virtualThreadsExecutor

Constructor Detail

ExecutorThreadPoolback to summary
public ExecutorThreadPool()
ExecutorThreadPoolback to summary
public ExecutorThreadPool(int maxThreads)
ExecutorThreadPoolback to summary
public ExecutorThreadPool(int maxThreads, int minThreads)
ExecutorThreadPoolback to summary
public ExecutorThreadPool(int maxThreads, int minThreads, BlockingQueue<Runnable> queue)
ExecutorThreadPoolback to summary
public ExecutorThreadPool(ThreadPoolExecutor executor)
ExecutorThreadPoolback to summary
public ExecutorThreadPool(ThreadPoolExecutor executor, int reservedThreads)
ExecutorThreadPoolback to summary
public ExecutorThreadPool(ThreadPoolExecutor executor, int reservedThreads, ThreadGroup group)
ExecutorThreadPoolback to summary
private ExecutorThreadPool(ThreadPoolExecutor executor, int minThreads, int reservedThreads, ThreadGroup group)

Method Detail

doStartback to summary
protected void doStart() throws Exception

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.doStart.

Doc from org.eclipse.jetty.util.component.ContainerLifeCycle.doStart.

Starts the managed lifecycle beans in the order they were added.

Annotations
@Override
Exceptions
Exception:

Doc from org.eclipse.jetty.util.component.AbstractLifeCycle.doStart.

If there was a problem starting. Will cause a transition to FAILED state

doStopback to summary
protected void doStop() throws Exception

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.doStop.

Doc from org.eclipse.jetty.util.component.ContainerLifeCycle.doStop.

Stops the managed lifecycle beans in the reverse order they were added.

Annotations
@Override
Exceptions
Exception:

Doc from org.eclipse.jetty.util.component.AbstractLifeCycle.doStop.

If there was a problem stopping. Will cause a transition to FAILED state

dumpback to summary
public void dump(Appendable out, String indent) throws IOException

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.dump.

Implements org.eclipse.jetty.util.component.Dumpable.dump.

Doc from org.eclipse.jetty.util.component.Dumpable.dump.

Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.

Parameters
out:Appendable

The appendable to dump to

indent:String

The indent to apply after any new lines.

Annotations
@Override
Exceptions
IOException:
if unable to write to Appendable
executeback to summary
public void execute(Runnable command)

Overrides default org.eclipse.jetty.util.thread.TryExecutor.execute.

Implements java.util.concurrent.Executor.execute.

Doc from java.util.concurrent.Executor.execute.

Executes the given command at some time in the future. The command may execute in a new thread, in a pooled thread, or in the calling thread, at the discretion of the Executor implementation.

Parameters
command:Runnable

the runnable task

Annotations
@Override
getIdleThreadsback to summary
public int getIdleThreads()

Implements org.eclipse.jetty.util.thread.ThreadPool.getIdleThreads.

Returns:int

Doc from org.eclipse.jetty.util.thread.ThreadPool.getIdleThreads.

The number of idle threads in the pool

Annotations
@Override
@ManagedAttribute:number of idle threads in the pool
getIdleTimeoutback to summary
public int getIdleTimeout()
Returns:int

the maximum thread idle time in ms.

Annotations
@ManagedAttribute:maximum time a thread may be idle in ms
See Also
setIdleTimeout(int)
getMaxThreadsback to summary
public int getMaxThreads()

Implements org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool.getMaxThreads.

Returns:int

Doc from org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool.getMaxThreads.

the maximum number of threads

Annotations
@Override
@ManagedAttribute:maximum number of threads in the pool
getMinThreadsback to summary
public int getMinThreads()

Implements org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool.getMinThreads.

Returns:int

Doc from org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool.getMinThreads.

the minimum number of threads

Annotations
@Override
@ManagedAttribute:minimum number of threads in the pool
getNameback to summary
public String getName()
Returns:String

the name of the this thread pool

Annotations
@ManagedAttribute:name of this thread pool
getReservedThreadsback to summary
public int getReservedThreads()
Returns:int

number of reserved threads or -1 to indicate that the number is heuristically determined

Annotations
@ManagedAttribute:the number of reserved threads in the pool
See Also
setReservedThreads(int)
getThreadPoolBudgetback to summary
public ThreadPoolBudget getThreadPoolBudget()

Overrides default org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool.getThreadPoolBudget.

Returns:ThreadPoolBudget

Doc from org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool.getThreadPoolBudget.

a ThreadPoolBudget for this sized thread pool, or null of no ThreadPoolBudget can be returned

Annotations
@Override
getThreadsback to summary
public int getThreads()

Implements org.eclipse.jetty.util.thread.ThreadPool.getThreads.

Returns:int

Doc from org.eclipse.jetty.util.thread.ThreadPool.getThreads.

The total number of threads currently in the pool

Annotations
@Override
@ManagedAttribute:number of threads in the pool
getThreadsPriorityback to summary
public int getThreadsPriority()
getVirtualThreadsExecutorback to summary
public Executor getVirtualThreadsExecutor()

Overrides default org.eclipse.jetty.util.VirtualThreads.Configurable.getVirtualThreadsExecutor.

Returns:Executor

Doc from org.eclipse.jetty.util.VirtualThreads.Configurable.getVirtualThreadsExecutor.

the Executor to use to execute tasks in virtual threads

Annotations
@Override
isDaemonback to summary
public boolean isDaemon()
Returns:boolean

whether this thread pool uses daemon threads

Annotations
@ManagedAttribute:whether this thread pool uses daemon threads
See Also
setDaemon(boolean)
isDetailedDumpback to summary
public boolean isDetailedDump()
Annotations
@ManagedAttribute:reports additional details in the dump
isLowOnThreadsback to summary
public boolean isLowOnThreads()

Implements org.eclipse.jetty.util.thread.ThreadPool.isLowOnThreads.

Returns:boolean

Doc from org.eclipse.jetty.util.thread.ThreadPool.isLowOnThreads.

True if the pool is low on threads

Annotations
@Override
@ManagedAttribute:thread pool is low on threads
readonly:true
joinback to summary
public void join() throws InterruptedException

Implements org.eclipse.jetty.util.thread.ThreadPool.join.

Doc from org.eclipse.jetty.util.thread.ThreadPool.join.

Blocks until the thread pool is stopped.

Annotations
@Override
Exceptions
InterruptedException:
if thread was interrupted
newThreadback to summary
protected Thread newThread(Runnable job)
setDaemonback to summary
public void setDaemon(boolean daemon)
Parameters
daemon:boolean

whether this thread pool uses daemon threads

See Also
Thread#setDaemon(boolean)
setDetailedDumpback to summary
public void setDetailedDump(boolean detailedDump)
setIdleTimeoutback to summary
public void setIdleTimeout(int idleTimeout)

Sets the maximum thread idle time in ms.

Threads that are idle for longer than this period may be stopped.

Parameters
idleTimeout:int

the maximum thread idle time in ms.

See Also
getIdleTimeout()
setMaxThreadsback to summary
public void setMaxThreads(int threads)

Implements org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool.setMaxThreads.

Parameters
threads:int

Doc from org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool.setMaxThreads.

the maximum number of threads

Annotations
@Override
setMinThreadsback to summary
public void setMinThreads(int threads)

Implements org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool.setMinThreads.

Parameters
threads:int

Doc from org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool.setMinThreads.

the minimum number of threads

Annotations
@Override
setNameback to summary
public void setName(String name)

Set the name of this thread pool, used to name threads.

Parameters
name:String

the name of this thread pool, used to name threads

setReservedThreadsback to summary
public void setReservedThreads(int reservedThreads)

Sets the number of reserved threads.

Parameters
reservedThreads:int

number of reserved threads or -1 to determine the number heuristically

See Also
getReservedThreads()
setThreadsPriorityback to summary
public void setThreadsPriority(int priority)
setVirtualThreadsExecutorback to summary
public void setVirtualThreadsExecutor(Executor executor)

Overrides default org.eclipse.jetty.util.VirtualThreads.Configurable.setVirtualThreadsExecutor.

Parameters
executor:Executor

Doc from org.eclipse.jetty.util.VirtualThreads.Configurable.setVirtualThreadsExecutor.

the Executor to use to execute tasks in virtual threads

Annotations
@Override
toStringback to summary
public String toString()

Overrides org.eclipse.jetty.util.component.AbstractLifeCycle.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
tryExecuteback to summary
public boolean tryExecute(Runnable task)

Implements org.eclipse.jetty.util.thread.TryExecutor.tryExecute.

Doc from org.eclipse.jetty.util.thread.TryExecutor.tryExecute.

Attempt to execute a task.

Parameters
task:Runnable

The task to be executed

Returns:boolean

True IFF the task has been given directly to a thread to execute. The task cannot be queued pending the later availability of a Thread.

Annotations
@Override