public class MyJobTest {
public static void main(String[] args) throws SchedulerException,
ParseException {
startSchedule();
//resumeJob();
}
/**
* simpleSchedule()
*/
public static void startSchedule() {
try {
// 1JobDetailQuartz
JobDetail jobDetail = JobBuilder.newJob(MyJob.class)
//
.withIdentity("job1_1", "jGroup1")
//
.build();
//
SimpleScheduleBuilder builder = SimpleScheduleBuilder
//
.repeatSecondlyForTotalCount(5);
//CronScheduleBuilder builder = CronScheduleBuilder.cronSchedule("0/2 * * * * ?");
// 2Trigger
Trigger trigger = TriggerBuilder.newTrigger()
.withIdentity("trigger1_1", "tGroup1").startNow()
.withSchedule(builder)
.build();
// 3Scheduler
Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
scheduler.start();
// 4
scheduler.scheduleJob(jobDetail, trigger);
try {
System.out.print(" 60000\n");
Thread.sleep(60000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//
scheduler.shutdown();
} catch (SchedulerException e) {
e.printStackTrace();
}
}
}