Interface ResizableExecutor
- All Superinterfaces:
Executor
- All Known Implementing Classes:
StandardThreadExecutor
Executor that supports dynamic resizing of the thread pool and queue.
-
Method Summary
Modifier and TypeMethodDescriptionintReturns the approximate number of threads that are actively executing tasks.intReturns the maximum number of threads in the pool.intReturns the current number of threads in the pool.booleanresizePool(int corePoolSize, int maximumPoolSize) Resize the thread pool.booleanresizeQueue(int capacity) Resize the work queue.
-
Method Details
-
getPoolSize
int getPoolSize()Returns the current number of threads in the pool.- Returns:
- the number of threads
-
getMaxThreads
int getMaxThreads()Returns the maximum number of threads in the pool.- Returns:
- the maximum number of threads
-
getActiveCount
int getActiveCount()Returns the approximate number of threads that are actively executing tasks.- Returns:
- the number of threads
-
resizePool
boolean resizePool(int corePoolSize, int maximumPoolSize) Resize the thread pool.- Parameters:
corePoolSize- The new core pool sizemaximumPoolSize- The new maximum pool size- Returns:
- True if the pool was resized successfully
-
resizeQueue
boolean resizeQueue(int capacity) Resize the work queue.- Parameters:
capacity- The new queue capacity- Returns:
- True if the queue was resized successfully
-