public class DynamicSizedSchedulerImpl extends ScheduledThreadPoolExecutor implements DynamicSizedSchedulerInterface
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy| Constructor and Description |
|---|
DynamicSizedSchedulerImpl(int corePoolSize)
Initialize a scheduler with dynamic pool size.
|
| Modifier and Type | Method and Description |
|---|---|
Future<?> |
addThreadAndExecute(Runnable task)
Used when you want to ensure an extra thread is available to execute task.
|
Future<?> |
addThreadAndSchedule(Runnable task,
long delay,
TimeUnit unit)
Used when you want to ensure an extra thread is available for scheduled task.
|
void |
adjustPoolSize(int delta)
Adjusts the pool size by a given delta.
|
void |
setPoolSize(int newSize)
Update the pool thread count with this new value.
|
decorateTask, decorateTask, execute, getContinueExistingPeriodicTasksAfterShutdownPolicy, getExecuteExistingDelayedTasksAfterShutdownPolicy, getQueue, getRemoveOnCancelPolicy, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, setContinueExistingPeriodicTasksAfterShutdownPolicy, setExecuteExistingDelayedTasksAfterShutdownPolicy, setRemoveOnCancelPolicy, shutdown, shutdownNow, submit, submit, submitafterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, terminated, toStringinvokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskForclone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitschedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelayawaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow, submit, submit, submitpublic DynamicSizedSchedulerImpl(int corePoolSize)
corePoolSize - initial Core pool sizepublic void setPoolSize(int newSize)
DynamicSizedSchedulerInterfacesetPoolSize in interface DynamicSizedSchedulerInterfacenewSize - New pool size that is superior to 0public void adjustPoolSize(int delta)
DynamicSizedSchedulerInterfaceadjustPoolSize in interface DynamicSizedSchedulerInterfacedelta - A positive or negative number to adjust the pool size by.public Future<?> addThreadAndExecute(Runnable task)
DynamicSizedSchedulerInterfaceaddThreadAndExecute in interface DynamicSizedSchedulerInterfacetask - Task to be executedpublic Future<?> addThreadAndSchedule(Runnable task, long delay, TimeUnit unit)
DynamicSizedSchedulerInterfaceaddThreadAndSchedule in interface DynamicSizedSchedulerInterfacetask - Task to be executeddelay - delay before executionunit - unit of delayCopyright © 2016. All rights reserved.