Quartz的resumeJob()为什么要执行两次作业?

时间:2019-01-02 13:52:23

标签: java

当我暂停工作时,等待10秒钟,恢复工作,为什么要运行两次?

JobDetail jobDetail = JobBuilder.newJob(QuartzStudy.class).withIdentity("job1").build();
        Trigger trigger = TriggerBuilder.newTrigger()
                .withSchedule(CronScheduleBuilder.cronSchedule("*/5 * * * * ?"))
                .build();
        scheduler.scheduleJob(jobDetail, trigger);
        Thread.sleep(10000);
        scheduler.pauseJob(jobDetail.getKey());
        Thread.sleep(10000);
        scheduler.resumeJob(jobDetail.getKey());
@Override
public void execute(JobExecutionContext jobExecutionContext) {
        System.out.println(jobExecutionContext.getJobDetail().getKey().getName() + "-" + Thread.currentThread().getName() + "-" + Thread.currentThread().getId() + "-" + new Date());
}

我在履历表()之后找到了两次日志

job1-DefaultQuartzScheduler_Worker-1-14-Wed Jan 02 21:50:55 CST 2019

job1-DefaultQuartzScheduler_Worker-2-15-Wed Jan 02 21:51:00 CST 2019

job1-DefaultQuartzScheduler_Worker-3-16-Wed Jan 02 21:51:11 CST 2019

job1-DefaultQuartzScheduler_Worker-4-17-Wed Jan 02 21:51:11 CST 2019

0 个答案:

没有答案