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
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceSpecialized sub-interface of ThreadPool that allows to get/set the minimum and maximum number of threads of the pool. - 
Method Summary
Modifier and TypeMethodDescriptionstatic voidexecuteImmediately(Executor executor, Runnable task) Execute a task immediately without queueing.intintbooleanvoidjoin()Blocks until the thread pool isstopped.static booleanRejects a job that cannot be executed. 
- 
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.
 - 
reject
 
 -