public abstract class Tasks extends Object
| 构造器和说明 |
|---|
Tasks() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
depose()
关闭定时任务服务
系统关闭时可调用此方法终止正在执行的定时任务,一旦关闭后不允许再向线程池中添加任务,否则会报RejectedExecutionException异常
|
static ScheduledThreadPoolExecutor |
getTaskScheduler()
返回定时任务线程池,可做更高级的应用
|
static void |
reset()
重启动定时任务服务
|
static void |
resizeThreadPool(int threadPoolSize)
调整线程池大小
|
static void |
scheduleAtFixedRate(Runnable task,
Date startTime,
long period,
TimeUnit unit)
在指定的时间点开始以固定的频率运行任务。
|
static ScheduledFuture<?> |
scheduleAtFixedRate(Runnable task,
long periodSeconds)
立即启动,并以固定的频率来运行任务。
|
static ScheduledFuture<?> |
scheduleAtFixedRate(Runnable task,
long initialDelay,
long periodSeconds,
TimeUnit unit)
在指定的延时之后开始以固定的频率来运行任务。
|
static void |
scheduleAtFixedRate(Runnable task,
String startTime,
long period,
TimeUnit unit)
在指定的时间点开始以固定的频率运行任务。
|
static void |
scheduleAtFixedTime(Runnable task,
Date startTime)
在指定的时间点启动任务只运行一次
|
static void |
scheduleAtFixedTime(Runnable task,
String expression)
在符合条件的时间点启动任务
|
static void |
scheduleWithFixedDelay(Runnable task,
Date startTime,
long period,
TimeUnit unit)
在指定的时间点启动,两次任务间保持固定的时间间隔
|
static ScheduledFuture<?> |
scheduleWithFixedDelay(Runnable task,
long periodSeconds)
立即启动,两次任务间保持固定的时间间隔
|
static ScheduledFuture<?> |
scheduleWithFixedDelay(Runnable task,
long initialDelay,
long period,
TimeUnit unit)
在指定的延时之后启动,两次任务间保持固定的时间间隔
|
static void |
scheduleWithFixedDelay(Runnable task,
String startTime,
long period,
TimeUnit unit)
在指定的时间点启动,两次任务间保持固定的时间间隔
|
public static ScheduledFuture<?> scheduleAtFixedRate(Runnable task, long periodSeconds)
task - 具体待执行的任务periodSeconds - 每次执行任务的间隔时间(单位秒)public static ScheduledFuture<?> scheduleAtFixedRate(Runnable task, long initialDelay, long periodSeconds, TimeUnit unit)
task - 具体待执行的任务initialDelay - 首次执行任务的延时时间periodSeconds - 每次执行任务的间隔时间(单位秒)unit - 时间单位public static void scheduleAtFixedRate(Runnable task, String startTime, long period, TimeUnit unit) throws ParseException
task - 具体待执行的任务startTime - 首次运行的时间点,支持 "yyyy-MM-dd HH:mm:ss" 格式period - 每次执行任务的间隔时间unit - 时间单位ParseExceptionpublic static void scheduleAtFixedRate(Runnable task, Date startTime, long period, TimeUnit unit)
task - 具体待执行的任务startTime - 首次运行的时间点period - 每次执行任务的间隔时间unit - 时间单位public static ScheduledFuture<?> scheduleWithFixedDelay(Runnable task, long periodSeconds)
task - 具体待执行的任务periodSeconds - 两次任务的间隔时间(单位秒)public static ScheduledFuture<?> scheduleWithFixedDelay(Runnable task, long initialDelay, long period, TimeUnit unit)
task - 具体待执行的任务initialDelay - 首次执行任务的延时时间period - 两次任务的间隔时间(单位秒)unit - 时间单位public static void scheduleWithFixedDelay(Runnable task, String startTime, long period, TimeUnit unit) throws ParseException
task - 具体待执行的任务startTime - 首次运行的时间点,支持 "yyyy-MM-dd HH:mm:ss" 格式period - 两次任务的间隔时间unit - 时间单位ParseExceptionpublic static void scheduleWithFixedDelay(Runnable task, Date startTime, long period, TimeUnit unit)
task - 具体待执行的任务startTime - 首次运行的时间点period - 两次任务的间隔时间unit - 时间单位public static void scheduleAtFixedTime(Runnable task, Date startTime)
task - 具体待执行的任务startTime - 运行的时间点public static void scheduleAtFixedTime(Runnable task, String expression)
task - 具体待执行的任务expression - 运行的时间点public static void resizeThreadPool(int threadPoolSize)
threadPoolSize - 线程池大小public static ScheduledThreadPoolExecutor getTaskScheduler()
public static void depose()
系统关闭时可调用此方法终止正在执行的定时任务,一旦关闭后不允许再向线程池中添加任务,否则会报RejectedExecutionException异常
public static void reset()
Copyright © 2017. All rights reserved.