0
我嘗試使用下面的代碼檢查Quartz Scheduler狀態,但狀態返回令人困惑。爲什麼在關閉調度程序後,isStarted狀態仍然爲true,在重新啓動調度程序後,isShutDown狀態爲true。Java Quartz Scheduler狀態
if (logger.isLoggable(Level.INFO)) {
logger.info("Before: Stand by: "
+ this.scheduler.isInStandbyMode() + ", Start: "
+ this.scheduler.isStarted() + ", Shutdown: "
+ this.scheduler.isShutdown());
}
this.scheduler.start();
if (logger.isLoggable(Level.INFO)) {
logger.info("After: Stand by: "
+ this.scheduler.isInStandbyMode() + ", Start: "
+ this.scheduler.isStarted() + ", Shutdown: "
+ this.scheduler.isShutdown());
}
//Shutdown scheduler
this.scheduler.shutdown(true);
if (logger.isLoggable(Level.INFO)) {
logger.info("Schedule stop: Stand by: "
+ this.scheduler.isInStandbyMode() + ", Start: "
+ this.scheduler.isStarted() + ", Shutdown: "
+ this.scheduler.isShutdown());
}
//Restart scheduler
this.scheduler.start();
if (logger.isLoggable(Level.INFO)) {
logger.info("schedule start: Stand by: "
+ this.scheduler.isInStandbyMode() + ", Start: "
+ this.scheduler.isStarted() + ", Shutdown: "
+ this.scheduler.isShutdown());
}
而結果回報
- 信息:前:站在一邊:真,開始:假的,關機:假
- INFO:後:通過支架:假的,啓動:真實,關機:假
- 信息:計劃停止:通過支架:真實,開始:真,關機:真
- 信息:計劃的開始:通過支架:真實,開始:真,關機:真