如何解决pauseJob,resumeJob执行多次后的问题?

时间:2019-01-04 07:49:06

标签: java quartz-scheduler

JobDetail jobDetail = JobBuilder.newJob(QuartzStudy.class).withIdentity("job1").build();
    CronTrigger trigger = TriggerBuilder.newTrigger()
            .startAt(DateBuilder.evenSecondDate(new Date()))
            .withSchedule(CronScheduleBuilder.cronSchedule("*/5 * * * * ?").withMisfireHandlingInstructionDoNothing())
            .build();
    scheduler.scheduleJob(jobDetail, trigger);
    Thread.sleep(10000);
    scheduler.pauseJob(jobDetail.getKey());
    Thread.sleep(10000);
    scheduler.resumeJob(jobDetail.getKey());

暂停作业后,Thead睡眠10s,然后恢复作业,但执行多次

job1-DefaultQuartzScheduler_Worker-1-14-Fri Jan 04 15:47:10 CST 2019

job1-DefaultQuartzScheduler_Worker-2-15-Fri Jan 04 15:47:15 CST 2019

job1-DefaultQuartzScheduler_Worker-3-16-Fri Jan 04 15:47:25 CST 2019

job1-DefaultQuartzScheduler_Worker-4-17-Fri Jan 04 15:47:25 CST 2019

0 个答案:

没有答案