以下是您可以运行以进行测试和了解的一些伪代码。
public class QuartzTest {
public static void main(String[] args) {
try {
// Grab the Scheduler instance from the Factory
Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
JobDetail job = newJob(HelloWord1.class)
.withIdentity("job1", "group1")
.build();
// Trigger the job to run now, and then repeat every 40 seconds
Trigger trigger = newTrigger()
.withIdentity("trigger1", "group1")
.startNow()
.withSchedule(simpleSchedule()
.withIntervalInSeconds(40)
.repeatForever())
.build();
// Tell quartz to schedule the job using our trigger
scheduler.start();
scheduler.scheduleJob(job, trigger);
scheduler.shutdown();
} catch (SchedulerException se) {
se.printStackTrace();
}
}
}