- java.lang.Object
- 
- java.util.concurrent.AbstractExecutorService
- 
- java.util.concurrent.ThreadPoolExecutor
- 
- io.helidon.common.configurable.ThreadPool
 
 
 
- 
- All Implemented Interfaces:
- Executor,- ExecutorService
 
 public class ThreadPool extends ThreadPoolExecutor AThreadPoolExecutorwith an extensible growth policy and queue state accessors.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classThreadPool.RejectionHandlerARejectedExecutionHandlerthat supports pool growth by re-attempting to add the task to the queue.- 
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutorThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
 
- 
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidafterExecute(Runnable r, Throwable t)static Optional<ThreadPool>asThreadPool(ExecutorService executor)Returns the given executor as aThreadPoolif possible.protected voidbeforeExecute(Thread t, Runnable r)intgetActiveThreads()Returns the current number of active threads.floatgetAverageActiveThreads()Returns the average number of active threads across the life of the pool.floatgetAverageQueueSize()Returns the average queue size.intgetCompletedTasks()Returns the number of completed tasks.intgetFailedTasks()Returns the number of tasks that threw an exception.StringgetName()Returns the name of this pool.intgetPeakQueueSize()Returns the peak queue size.io.helidon.common.configurable.ThreadPool.WorkQueuegetQueue()intgetQueueCapacity()Returns the queue capacity.intgetQueueSize()Returns the current number of tasks in the queue.ThreadPool.RejectionHandlergetRejectedExecutionHandler()intgetRejectionCount()Returns the rejection count.intgetTotalTasks()Returns the number of completed and failed tasks.booleanisFixedSize()Tests whether or not the number of threads can change over time.voidsetMaximumPoolSize(int maximumPoolSize)voidsetRejectedExecutionHandler(RejectedExecutionHandler handler)voidshutdown()List<Runnable>shutdownNow()StringtoString()- 
Methods inherited from class java.util.concurrent.ThreadPoolExecutorallowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setThreadFactory, terminated
 - 
Methods inherited from class java.util.concurrent.AbstractExecutorServiceinvokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
 
- 
 
- 
- 
- 
Method Detail- 
asThreadPoolpublic static Optional<ThreadPool> asThreadPool(ExecutorService executor) Returns the given executor as aThreadPoolif possible.- Parameters:
- executor- The executor.
- Returns:
- The thread pool or empty if not a ThreadPool.
 
 - 
getNamepublic String getName() Returns the name of this pool.- Returns:
- The name.
 
 - 
getQueueCapacitypublic int getQueueCapacity() Returns the queue capacity.- Returns:
- The capacity.
 
 - 
getAverageQueueSizepublic float getAverageQueueSize() Returns the average queue size.- Returns:
- The size.
 
 - 
getPeakQueueSizepublic int getPeakQueueSize() Returns the peak queue size.- Returns:
- The size.
 
 - 
getCompletedTaskspublic int getCompletedTasks() Returns the number of completed tasks.- Returns:
- The count.
 
 - 
getFailedTaskspublic int getFailedTasks() Returns the number of tasks that threw an exception.- Returns:
- The count.
 
 - 
getTotalTaskspublic int getTotalTasks() Returns the number of completed and failed tasks.- Returns:
- The count.
 
 - 
getActiveThreadspublic int getActiveThreads() Returns the current number of active threads.- Returns:
- The count.
 
 - 
getAverageActiveThreadspublic float getAverageActiveThreads() Returns the average number of active threads across the life of the pool.- Returns:
- The average.
 
 - 
getRejectionCountpublic int getRejectionCount() Returns the rejection count.- Returns:
- The count.
 
 - 
isFixedSizepublic boolean isFixedSize() Tests whether or not the number of threads can change over time.- Returns:
- trueif maximum size is equal to core size.
 
 - 
getQueuepublic io.helidon.common.configurable.ThreadPool.WorkQueue getQueue() - Overrides:
- getQueuein class- ThreadPoolExecutor
 
 - 
getQueueSizepublic int getQueueSize() Returns the current number of tasks in the queue.- Returns:
- The count.
 
 - 
setRejectedExecutionHandlerpublic void setRejectedExecutionHandler(RejectedExecutionHandler handler) - Overrides:
- setRejectedExecutionHandlerin class- ThreadPoolExecutor
 
 - 
getRejectedExecutionHandlerpublic ThreadPool.RejectionHandler getRejectedExecutionHandler() - Overrides:
- getRejectedExecutionHandlerin class- ThreadPoolExecutor
 
 - 
setMaximumPoolSizepublic void setMaximumPoolSize(int maximumPoolSize) - Overrides:
- setMaximumPoolSizein class- ThreadPoolExecutor
 
 - 
toStringpublic String toString() - Overrides:
- toStringin class- ThreadPoolExecutor
 
 - 
beforeExecuteprotected void beforeExecute(Thread t, Runnable r) - Overrides:
- beforeExecutein class- ThreadPoolExecutor
 
 - 
afterExecuteprotected void afterExecute(Runnable r, Throwable t) - Overrides:
- afterExecutein class- ThreadPoolExecutor
 
 - 
shutdownpublic void shutdown() - Specified by:
- shutdownin interface- ExecutorService
- Overrides:
- shutdownin class- ThreadPoolExecutor
 
 - 
shutdownNowpublic List<Runnable> shutdownNow() - Specified by:
- shutdownNowin interface- ExecutorService
- Overrides:
- shutdownNowin class- ThreadPoolExecutor
 
 
- 
 
-