日期:2014-05-20 浏览次数:21002 次
public class Test_1 { public Scheduler createScheduler() throws Exception { SchedulerFactory sf = new StdSchedulerFactory("Quartz.properties"); Scheduler scheduler = sf.getScheduler(); scheduler.scheduleJob(createJobDetail_1(), createCronTrigger_1()); [color=#FF0000]// 下面这一行,是我添加的另外一个作用的调度计划,问题就出在这[/color] scheduler.scheduleJob(createJobDetail_2(), createCronTrigger_2()); return scheduler; } private JobDetail createJobDetail_1() { JobDetail job = new JobDetail(DemoJob_1.class.getName(), Scheduler.DEFAULT_GROUP, DemoJob_1.class); return job; } private CronTrigger createCronTrigger_1() throws ParseException { CronTrigger trigger = new org.quartz.CronTrigger("DEFAULT", null); trigger.setJobName(DemoJob_1.class.getName()); trigger.setCronExpression(" 0/5 * * * * ? "); return trigger; } private JobDetail createJobDetail_2() { JobDetail job = new JobDetail(DemoJob_2.class.getName(), Scheduler.DEFAULT_GROUP, DemoJob_2.class); return job; } private CronTrigger createCronTrigger_2() throws ParseException { CronTrigger trigger = new org.quartz.CronTrigger("DEFAULT", null); trigger.setJobName(DemoJob_2.class.getName()); trigger.setCronExpression(" 0/15 * * * * ? "); return trigger; } } public class DemoJob_1 implements Job { @Override public void execute(JobExecutionContext arg0) throws JobExecutionException { System.out.println("DemoJob_1 demo output :" + new Date()); } } public class DemoJob_2 implements Job { @Override public void execute(JobExecutionContext arg0) throws JobExecutionException { System.out.println("DemoJob_2 demo output :" + new Date()); } } public class DemoTest { public static void main(String [] args) throws SchedulerException, Exception{ Test_1 test_1 = new Test_1(); test_1.createScheduler().start(); } }