1.http://blog.csdn.net/pdw2009/article/details/50195639
Your job class needs to implement StatefulJob
, or alternatively, if you are using Quartz 2.x, be annotated with @DisallowConcurrentExecution
.
This is how concurrent execution can be controlled in Quartz, and in particular MethodInvokingJobDetailFactoryBean
just uses different job classes depending on the value of concurrent
.
StatefulJob接口
2、 在job类前加上@DisallowConcurrentExecution
有时我们不希望程序一次动就执行job等 待下次触发,在quartz.properties中加上:
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread=true
2.https://my.oschina.net/liujiawan/blog/503697?p={{page}}
在执行定时任务的时候,把定时任务的时间设置为10分钟执行一次,由于数据量很大,第一个十分钟还没执行结束,第二个十分钟已经开始了,这样就造成了并发,但是又不想用
java中的锁,这样很纠结,在网上找了好多资料
其实很简单,我们只要在detail的参数里加上一句话就行了,把这个job设置成有状态的job
<property name="concurrent" value="false" /> ③ 指定最终封装出的任务是否有状态
通过concurrent属性指定任务的类型,默认情况下封装为无状态的任务,如果希望目标封装为有状态的任务,仅需要将concurrent设置为false就可以了。Spring通过名为concurrent的属性指定任务的类型,能够更直接地描述到任务执行的方式(有状态的任务不能并发执行,无状态的任务可并发执行)
3.http://blog.csdn.net/tiantangpw/article/details/41120137
4.https://zhidao.baidu.com/question/414090365.html
5.http://www.oschina.net/question/436266_129634%3Fsort%3Dtime?sort=time
不并发有两种方式:
1、使用spring xml配置,对jobDetail bean的concurrent属性设置为false;(隐约记得不写默认好像也是false)(推荐)
2、将job设置成有状态,即继承statefuljob接口。这个比较麻烦,不推荐使用。
3、或者将quartz properties配置中的连接池大小,改为1,这样肯定就不能并行(不推荐)
4、可以使用类静态变量标识是否当前job正在运行
6.
7.