use of com.example.quartz.QuartzManager in project java-example by 1479005017.
the class QuartzTest method test.
@Test
public void test() throws Exception {
SchedulerFactory schedulerFactory = new StdSchedulerFactory();
Scheduler scheduler = schedulerFactory.getScheduler();
QuartzManager quartzManager = new QuartzManager(scheduler);
// 每1000毫秒执行一次,重复执行3次,共执行4次
quartzManager.addJob("myJob", "test", MyJob.class, Collections.singletonMap("x", "1"), 1000L, 3);
quartzManager.startScheduler();
while (Thread.activeCount() > 0) Thread.yield();
}
use of com.example.quartz.QuartzManager in project java-example by 1479005017.
the class QuartzTest method testModify.
@Test
public void testModify() throws Exception {
SchedulerFactory schedulerFactory = new StdSchedulerFactory();
Scheduler scheduler = schedulerFactory.getScheduler();
QuartzManager quartzManager = new QuartzManager(scheduler);
quartzManager.addJob("myJob", "test", MyJob.class, Collections.singletonMap("x", "1"), "0/5 * * * * ?");
quartzManager.startScheduler();
Thread.sleep(1500);
for (int i = 0; Thread.activeCount() > 0; i++) {
if (i % 3 == 0) {
quartzManager.modifyJob("myJob", "test", Collections.singletonMap("x", i + ""));
}
Thread.sleep(1000);
}
}
Aggregations