类 ThreadPoolTaskScheduler
- 所有已实现的接口:
Aware,BeanNameAware,DisposableBean,InitializingBean,cn.taketoday.core.task.AsyncListenableTaskExecutor,cn.taketoday.core.task.AsyncTaskExecutor,cn.taketoday.core.task.TaskExecutor,SchedulingTaskExecutor,TaskScheduler,Serializable,Executor,ThreadFactory
TaskScheduler interface, wrapping
a native ScheduledThreadPoolExecutor.- 从以下版本开始:
- 4.0
- 作者:
- Juergen Hoeller, Mark Fisher
- 另请参阅:
-
setPoolSize(int)setRemoveOnCancelPolicy(boolean)setContinueExistingPeriodicTasksAfterShutdownPolicy(boolean)setExecuteExistingDelayedTasksAfterShutdownPolicy(boolean)ExecutorConfigurationSupport.setThreadFactory(java.util.concurrent.ThreadFactory)setErrorHandler(cn.taketoday.util.ErrorHandler)- 序列化表格
-
字段概要
从类继承的字段 cn.taketoday.scheduling.concurrent.ExecutorConfigurationSupport
logger从接口继承的字段 cn.taketoday.core.task.AsyncTaskExecutor
TIMEOUT_IMMEDIATE, TIMEOUT_INDEFINITE -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected voidcancelRemainingTask(Runnable task) Cancel the given remaining task which never commended execution, as returned fromExecutorService.shutdownNow().protected ScheduledExecutorServicecreateExecutor(int poolSize, ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) Create a newScheduledExecutorServiceinstance.voidvoidintReturn the number of currently active threads.getClock()Return the clock to use for scheduling purposes.intReturn the current pool size.Return the underlying ScheduledExecutorService for native access.Return the underlying ScheduledThreadPoolExecutor, if available.protected ExecutorServiceinitializeExecutor(ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) Create the targetExecutorServiceinstance.Schedule the givenRunnable, invoking it whenever the trigger indicates a next execution time.Schedule the givenRunnable, invoking it at the specified execution time.scheduleAtFixedRate(Runnable task, Duration period) Schedule the givenRunnable, starting as soon as possible and invoking it with the given period.scheduleAtFixedRate(Runnable task, Instant startTime, Duration period) Schedule the givenRunnable, invoking it at the specified execution time and subsequently with the given period.scheduleWithFixedDelay(Runnable task, Duration delay) Schedule the givenRunnable, starting as soon as possible and invoking it with the given delay between the completion of one execution and the start of the next.scheduleWithFixedDelay(Runnable task, Instant startTime, Duration delay) Schedule the givenRunnable, invoking it at the specified execution time and subsequently with the given delay between the completion of one execution and the start of the next.voidSet the clock to use for scheduling purposes.voidsetContinueExistingPeriodicTasksAfterShutdownPolicy(boolean flag) Set whether to continue existing periodic tasks even when this executor has been shutdown.voidsetErrorHandler(cn.taketoday.util.ErrorHandler errorHandler) Set a customErrorHandlerstrategy.voidsetExecuteExistingDelayedTasksAfterShutdownPolicy(boolean flag) Set whether to execute existing delayed tasks even when this executor has been shutdown.voidsetPoolSize(int poolSize) Set the ScheduledExecutorService's pool size.voidsetRemoveOnCancelPolicy(boolean flag) Set the remove-on-cancel mode onScheduledThreadPoolExecutor.Future<?><T> Future<T>cn.taketoday.util.concurrent.ListenableFuture<?>submitListenable(Runnable task) <T> cn.taketoday.util.concurrent.ListenableFuture<T>submitListenable(Callable<T> task) 从类继承的方法 cn.taketoday.scheduling.concurrent.ExecutorConfigurationSupport
afterPropertiesSet, destroy, initialize, setAwaitTerminationMillis, setAwaitTerminationSeconds, setBeanName, setRejectedExecutionHandler, setThreadFactory, setThreadNamePrefix, setWaitForTasksToCompleteOnShutdown, shutdown从类继承的方法 cn.taketoday.scheduling.concurrent.CustomizableThreadFactory
newThread从类继承的方法 cn.taketoday.util.CustomizableThreadCreator
createThread, getDefaultThreadNamePrefix, getThreadGroup, getThreadNamePrefix, getThreadPriority, isDaemon, nextThreadName, setDaemon, setThreadGroup, setThreadGroupName, setThreadPriority从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.core.task.AsyncTaskExecutor
submitCompletable, submitCompletable从接口继承的方法 cn.taketoday.scheduling.SchedulingTaskExecutor
prefersShortLivedTasks从接口继承的方法 cn.taketoday.scheduling.TaskScheduler
schedule, scheduleAtFixedRate, scheduleAtFixedRate, scheduleWithFixedDelay, scheduleWithFixedDelay
-
构造器详细资料
-
ThreadPoolTaskScheduler
public ThreadPoolTaskScheduler()
-
-
方法详细资料
-
setPoolSize
public void setPoolSize(int poolSize) Set the ScheduledExecutorService's pool size. Default is 1.This setting can be modified at runtime, for example through JMX.
-
setRemoveOnCancelPolicy
public void setRemoveOnCancelPolicy(boolean flag) Set the remove-on-cancel mode onScheduledThreadPoolExecutor.Default is
false. If set totrue, the target executor will be switched into remove-on-cancel mode (if possible).This setting can be modified at runtime, for example through JMX.
-
setContinueExistingPeriodicTasksAfterShutdownPolicy
public void setContinueExistingPeriodicTasksAfterShutdownPolicy(boolean flag) Set whether to continue existing periodic tasks even when this executor has been shutdown.Default is
false. If set totrue, the target executor will be switched into continuing periodic tasks (if possible).This setting can be modified at runtime, for example through JMX.
-
setExecuteExistingDelayedTasksAfterShutdownPolicy
public void setExecuteExistingDelayedTasksAfterShutdownPolicy(boolean flag) Set whether to execute existing delayed tasks even when this executor has been shutdown.Default is
true. If set tofalse, the target executor will be switched into dropping remaining tasks (if possible).This setting can be modified at runtime, for example through JMX.
-
setErrorHandler
public void setErrorHandler(cn.taketoday.util.ErrorHandler errorHandler) Set a customErrorHandlerstrategy. -
setClock
Set the clock to use for scheduling purposes.The default clock is the system clock for the default time zone.
-
getClock
从接口复制的说明:TaskSchedulerReturn the clock to use for scheduling purposes.- 指定者:
getClock在接口中TaskScheduler- 另请参阅:
-
initializeExecutor
protected ExecutorService initializeExecutor(ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) 从类复制的说明:ExecutorConfigurationSupportCreate the targetExecutorServiceinstance. Called byafterPropertiesSet.- 指定者:
initializeExecutor在类中ExecutorConfigurationSupport- 参数:
threadFactory- the ThreadFactory to userejectedExecutionHandler- the RejectedExecutionHandler to use- 返回:
- a new ExecutorService instance
- 另请参阅:
-
createExecutor
protected ScheduledExecutorService createExecutor(int poolSize, ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) Create a newScheduledExecutorServiceinstance.The default implementation creates a
ScheduledThreadPoolExecutor. Can be overridden in subclasses to provide customScheduledExecutorServiceinstances.- 参数:
poolSize- the specified pool sizethreadFactory- the ThreadFactory to userejectedExecutionHandler- the RejectedExecutionHandler to use- 返回:
- a new ScheduledExecutorService instance
- 另请参阅:
-
getScheduledExecutor
Return the underlying ScheduledExecutorService for native access.- 返回:
- the underlying ScheduledExecutorService (never
null) - 抛出:
IllegalStateException- if the ThreadPoolTaskScheduler hasn't been initialized yet
-
getScheduledThreadPoolExecutor
Return the underlying ScheduledThreadPoolExecutor, if available.- 返回:
- the underlying ScheduledExecutorService (never
null) - 抛出:
IllegalStateException- if the ThreadPoolTaskScheduler hasn't been initialized yet or if the underlying ScheduledExecutorService isn't a ScheduledThreadPoolExecutor- 另请参阅:
-
getPoolSize
public int getPoolSize()Return the current pool size.Requires an underlying
ScheduledThreadPoolExecutor. -
getActiveCount
public int getActiveCount()Return the number of currently active threads.Requires an underlying
ScheduledThreadPoolExecutor. -
execute
-
execute
- 指定者:
execute在接口中cn.taketoday.core.task.AsyncTaskExecutor
-
submit
- 指定者:
submit在接口中cn.taketoday.core.task.AsyncTaskExecutor
-
submit
- 指定者:
submit在接口中cn.taketoday.core.task.AsyncTaskExecutor
-
submitListenable
- 指定者:
submitListenable在接口中cn.taketoday.core.task.AsyncListenableTaskExecutor
-
submitListenable
- 指定者:
submitListenable在接口中cn.taketoday.core.task.AsyncListenableTaskExecutor
-
cancelRemainingTask
从类复制的说明:ExecutorConfigurationSupportCancel the given remaining task which never commended execution, as returned fromExecutorService.shutdownNow().- 覆盖:
cancelRemainingTask在类中ExecutorConfigurationSupport- 参数:
task- the task to cancel (typically aRunnableFuture)- 另请参阅:
-
schedule
从接口复制的说明:TaskSchedulerSchedule the givenRunnable, invoking it whenever the trigger indicates a next execution time.Execution will end once the scheduler shuts down or the returned
ScheduledFuturegets cancelled.- 指定者:
schedule在接口中TaskScheduler- 参数:
task- the Runnable to execute whenever the trigger firestrigger- an implementation of theTriggerinterface, e.g. aCronTriggerobject wrapping a cron expression- 返回:
- a
ScheduledFuturerepresenting pending completion of the task, ornullif the given Trigger object never fires (i.e. returnsnullfromTrigger.nextExecutionTime(cn.taketoday.scheduling.TriggerContext)) - 另请参阅:
-
schedule
从接口复制的说明:TaskSchedulerSchedule the givenRunnable, invoking it at the specified execution time.Execution will end once the scheduler shuts down or the returned
ScheduledFuturegets cancelled.- 指定者:
schedule在接口中TaskScheduler- 参数:
task- the Runnable to execute whenever the trigger firesstartTime- the desired execution time for the task (if this is in the past, the task will be executed immediately, i.e. as soon as possible)- 返回:
- a
ScheduledFuturerepresenting pending completion of the task
-
scheduleAtFixedRate
从接口复制的说明:TaskSchedulerSchedule the givenRunnable, invoking it at the specified execution time and subsequently with the given period.Execution will end once the scheduler shuts down or the returned
ScheduledFuturegets cancelled.- 指定者:
scheduleAtFixedRate在接口中TaskScheduler- 参数:
task- the Runnable to execute whenever the trigger firesstartTime- the desired first execution time for the task (if this is in the past, the task will be executed immediately, i.e. as soon as possible)period- the interval between successive executions of the task- 返回:
- a
ScheduledFuturerepresenting pending completion of the task
-
scheduleAtFixedRate
从接口复制的说明:TaskSchedulerSchedule the givenRunnable, starting as soon as possible and invoking it with the given period.Execution will end once the scheduler shuts down or the returned
ScheduledFuturegets cancelled.- 指定者:
scheduleAtFixedRate在接口中TaskScheduler- 参数:
task- the Runnable to execute whenever the trigger firesperiod- the interval between successive executions of the task- 返回:
- a
ScheduledFuturerepresenting pending completion of the task
-
scheduleWithFixedDelay
从接口复制的说明:TaskSchedulerSchedule the givenRunnable, invoking it at the specified execution time and subsequently with the given delay between the completion of one execution and the start of the next.Execution will end once the scheduler shuts down or the returned
ScheduledFuturegets cancelled.- 指定者:
scheduleWithFixedDelay在接口中TaskScheduler- 参数:
task- the Runnable to execute whenever the trigger firesstartTime- the desired first execution time for the task (if this is in the past, the task will be executed immediately, i.e. as soon as possible)delay- the delay between the completion of one execution and the start of the next- 返回:
- a
ScheduledFuturerepresenting pending completion of the task
-
scheduleWithFixedDelay
从接口复制的说明:TaskSchedulerSchedule the givenRunnable, starting as soon as possible and invoking it with the given delay between the completion of one execution and the start of the next.Execution will end once the scheduler shuts down or the returned
ScheduledFuturegets cancelled.- 指定者:
scheduleWithFixedDelay在接口中TaskScheduler- 参数:
task- the Runnable to execute whenever the trigger firesdelay- the delay between the completion of one execution and the start of the next- 返回:
- a
ScheduledFuturerepresenting pending completion of the task - 另请参阅:
-