标签:style color io os 使用 ar java for sp
创建Scheduler一般都是
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
package scheduler;import org.junit.Test;import org.quartz.*;import org.quartz.impl.StdSchedulerFactory;public class SchedulerTest { @Test public void test1(){ try { Scheduler sc=new StdSchedulerFactory().getDefaultScheduler(); } catch (SchedulerException e) { e.printStackTrace(); } }} |
这种情况下使用的是默认调度器,在quartz.properties中已经把属性全部设置好了,看代码
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
org.quartz.scheduler.instanceName: DefaultQuartzSchedulerorg.quartz.scheduler.rmi.export: falseorg.quartz.scheduler.rmi.proxy: falseorg.quartz.scheduler.wrapJobExecutionInUserTransaction: falseorg.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPoolorg.quartz.threadPool.threadCount: 10//Thread数量org.quartz.threadPool.threadPriority: 5//Thread优先级org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread: trueorg.quartz.jobStore.misfireThreshold: 60000 //将schedule相关信息保存在ram中,轻量级速度快,遗憾的是重启应用时会丢失org.quartz.jobStore.class: org.quartz.simpl.RAMJobSto |
我们可以自己配置相关的信息,比如thread的数量
代码如下:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
package scheduler;import java.util.Properties;//两个quartz包不可以少import org.quartz.*;import org.quartz.impl.StdSchedulerFactory;public class SchedulerTest { private static SchedulerFactory scf=new StdSchedulerFactory(); static{ Properties pr=new Properties(); //将thread数量设置为50 pr.put("org.quartz.threadPool.threadCount", "50"); try { ((StdSchedulerFactory) scf).initialize(pr); } catch (SchedulerException e) { e.printStackTrace(); } }} |
运行之后,会发现已经thread数量已经变化
|
1
2
3
4
5
6
|
Scheduler class: ‘org.quartz.core.QuartzScheduler‘ - running locally. NOT STARTED. Currently in standby mode. Number of jobs executed: 0 Using thread pool ‘org.quartz.simpl.SimpleThreadPool‘ - with 50 threads. Using job-store ‘org.quartz.simpl.RAMJobStore‘ - which does not support persistence. and is not clustered. |
标签:style color io os 使用 ar java for sp
原文地址:http://www.cnblogs.com/jiejiecool/p/4015998.html