public class ScheduledService extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
MODE_FIXEDDELAY
固定间隔执行,执行完成后才计算间隔
|
static int |
MODE_FIXEDRATE
固定频率执行,按执行开始时间计算间隔
|
protected static boolean |
resetting
正在重置标识
|
protected static Map<ScheduledService,Long> |
SCHEDULED_SERVICE_MAP
缓存了目前全部的定时任务, 用于重建
|
| 构造器和说明 |
|---|
ScheduledService(String threadName,
int mode,
Runnable runnable,
long initialDelay,
long period,
TimeUnit unit)
Instantiates a new Scheduled service.
|
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
isResetting()
是否正在重置
|
boolean |
isStarted()
是否已经启动
|
static void |
reset()
重建定时任务,用于特殊情况
|
void |
shutdown()
停止执行定时任务,还可以重新start
|
ScheduledService |
start()
开始执行定时任务
|
void |
stop()
停止执行定时任务,还可以重新start
|
public static final int MODE_FIXEDRATE
public static final int MODE_FIXEDDELAY
protected static final Map<ScheduledService,Long> SCHEDULED_SERVICE_MAP
protected static volatile boolean resetting
public ScheduledService(String threadName, int mode, Runnable runnable, long initialDelay, long period, TimeUnit unit)
threadName - the thread namemode - the moderunnable - the runnableinitialDelay - the initial delayperiod - the periodunit - the unitpublic ScheduledService start()
public void stop()
public void shutdown()
public boolean isStarted()
public static void reset()
public static boolean isResetting()
Copyright © 2008–2018 The Ant Financial. All rights reserved.