Package org.eclipse.jetty.util.thread
Interface ThreadPool
- All Superinterfaces:
Executor
- All Known Subinterfaces:
ThreadPool.SizedThreadPool
- All Known Implementing Classes:
DelegatingThreadPool
,ExecutorThreadPool
,MonitoredQueuedThreadPool
,QueuedThreadPool
,VirtualThreadPool
A pool for threads.
A specialization of Executor interface that provides reporting methods (eg getThreads()
)
and the option of configuration methods (e.g. @link ThreadPool.SizedThreadPool.setMaxThreads(int)
).
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Specialized sub-interface of ThreadPool that allows to get/set the minimum and maximum number of threads of the pool. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
executeImmediately
(Executor executor, Runnable task) Execute a task immediately without queueing.int
int
boolean
void
join()
Blocks until the thread pool isstopped
.
-
Method Details
-
join
Blocks until the thread pool isstopped
.- Throws:
InterruptedException
- if thread was interrupted
-
getThreads
- Returns:
- The total number of threads currently in the pool
-
getIdleThreads
- Returns:
- The number of idle threads in the pool
-
isLowOnThreads
- Returns:
- True if the pool is low on threads
-
executeImmediately
Execute a task immediately without queueing. This may use a
ReservedThread
, aVirtual Thread
, a call toInvocable.invokeNonBlocking(Runnable)
, a newly spawned thread, or direct execution.- Parameters:
executor
- An executor that may be usedtask
- The task that must be executed.
-