上一篇简单的使用了一下quartz,然而在实际开发中可能存在n多种情况,针对可能出现的问题进行了测试。
1、一秒执行一次,执行10次,那么当一次的执行时间是大于一秒的时候会出现什么状况?
测试如下:在QuartzJobFactory类的重写方法中加入线程的阻塞,模拟实际执行一次的的时间大于一秒的情况。
public void execute(JobExecutionContext context) throws JobExecutionException {
long start = System.currentTimeMillis();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("等待:"+(System.currentTimeMillis()-sta