1.加载包

2.添加quartz.propertes

3.编写自己的任务类

4.添加自动任务配置

5.通过 quartzProperties 配置连接池

1.加载包

<dependency>
<groupId>quartz</groupId>
<artifactId>quartz</artifactId>
<version>1.5.</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>

2.添加quartz.propertes

从quartz.jar中copy一份quartz.properties 放在项目资源目录下

修改线程池数量

org.quartz.threadPool.threadCount = 1

# Default Properties file for use by StdSchedulerFactory
# to create a Quartz Scheduler Instance, if a different
# properties file is not explicitly specified.
# org.quartz.scheduler.instanceName = DefaultQuartzScheduler
org.quartz.scheduler.rmi.export = false
org.quartz.scheduler.rmi.proxy = false
org.quartz.scheduler.wrapJobExecutionInUserTransaction = false org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
#thread pool count
org.quartz.threadPool.threadCount =
org.quartz.threadPool.threadPriority =
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true org.quartz.jobStore.misfireThreshold = org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore

3.编写自己的任务类

com.qi.task.RiskManagermentJob

4.添加自动任务配置

需要添加

 <property name="configLocation" value="classpath:quartz.properties"></property>
不添加,配置的线程池数将不生效。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <bean id="riskManagermentJob" class="com.qi.task.RiskManagermentJob" />
<bean id="SpringQtzJobMethod"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject">
<ref bean="riskManagermentJob" />
</property>
<property name="targetMethod">
<value>execute</value>
</property>
</bean> <!-- ======================== 调度触发器 ======================== -->
<bean id="CronTriggerBean" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="SpringQtzJobMethod"></property>
<property name="cronExpression" value="2/60 * 15 * * ?"></property>
</bean> <!-- ======================== 调度工厂 ======================== -->
<bean id="SpringJobSchedulerFactoryBean"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="CronTriggerBean" />
</list>
</property>
<property name="configLocation" value="classpath:quartz.properties"></property>
</bean> </beans>

5.通过 quartzProperties 配置连接池

<bean id="SpringJobSchedulerFactoryBean"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="CronTriggerBean" />
</list>
</property>
<property name="quartzProperties">
<props>
<prop key="org.quartz.threadPool.threadCount"></prop>
</props>
</property>
<!-- 方式二 -->
<!-- <property name="configLocation" value="classpath:quartz.properties"></property> -->
</bean>

quartz自定义线程数的更多相关文章

  1. quartz 使用配置文件配置线程数

    quartz默认的线程数是10个,如果我们要修改这个线程数需要做一个配置文件,在配置文件内修改线程. 一共需要2个操作: 1.找到quartz的XML配置文件,设置加载配置文件(配置文件存放在weba ...

  2. Android线程管理之ThreadPoolExecutor自定义线程池

    前言: 上篇主要介绍了使用线程池的好处以及ExecutorService接口,然后学习了通过Executors工厂类生成满足不同需求的简单线程池,但是有时候我们需要相对复杂的线程池的时候就需要我们自己 ...

  3. 【原创】如何确定Kafka的分区数、key和consumer线程数

    在Kafak中国社区的qq群中,这个问题被提及的比例是相当高的,这也是Kafka用户最常碰到的问题之一.本文结合Kafka源码试图对该问题相关的因素进行探讨.希望对大家有所帮助.   怎么确定分区数? ...

  4. Android AsyncTask 深度理解、简单封装、任务队列分析、自定义线程池

    前言:由于最近在做SDK的功能,需要设计线程池.看了很多资料不知道从何开始着手,突然发现了AsyncTask有对线程池的封装,so,就拿它开刀,本文将从AsyncTask的基本用法,到简单的封装,再到 ...

  5. Android 自定义线程池的实战

    前言:在上一篇文章中我们讲到了AsyncTask的基本使用.AsyncTask的封装.AsyncTask 的串行/并行线程队列.自定义线程池.线程池的快速创建方式. 对线程池不了解的同学可以先看 An ...

  6. 【转】如何确定Kafka的分区数、key和consumer线程数

    文章来源:http://www.cnblogs.com/huxi2b/p/4583249.html -------------------------------------------------- ...

  7. 介绍开源的.net通信框架NetworkComms框架 源码分析(十五 ) CommsThreadPool自定义线程池

    原文网址: http://www.cnblogs.com/csdev Networkcomms 是一款C# 语言编写的TCP/UDP通信框架  作者是英国人  以前是收费的 目前作者已经开源  许可是 ...

  8. python_way day11 自定义线程池

    python_way day11 线程池 为什么需要线程池 线程多一些固然好,但是过多的线程反倒影响系统的负荷,所以我们就需要创建合适多的线程,哪我们把线程放到哪里?这时就放到线程池中. 线程池中存放 ...

  9. python自定义线程池

    关于python的多线程,由与GIL的存在被广大群主所诟病,说python的多线程不是真正的多线程.但多线程处理IO密集的任务效率还是可以杠杠的. 我实现的这个线程池其实是根据银角的思路来实现的. 主 ...

随机推荐

  1. Shell脚本字体颜色

    [root@web01 scripts]# man console_codesecho -e "\033[背景颜色:字体颜色m字符串\033[0m",例:echo -e " ...

  2. 20171104xlVBA制作联合成绩条

    Dim dGoal As Object Dim dCls As Object Sub 制作联合成绩条() Dim sht As Worksheet Dim HeadRng As Range Dim H ...

  3. Spring Batch 背景

    在开源项目及其相关社区把大部分注意力集中在基于 web 和 SOA 基于消息机制的框架中时,基于 Java 的批处理框架却无人问津,尽管在企业 T 环境中一直都有这种批处理的需求.但因为缺乏一个标准的 ...

  4. csrf漏洞

    漏洞原理:csrf全名为跨站请求伪造,是一种对网站的恶意利用,虽然听起来和xss很像,但是它们俩还是有很大的区别的.csrf是通过伪造来自受信任用户的请求来利用受信任的网站. 比如: 一个有csrf漏 ...

  5. python中lambda的用法

    一.lambda函数也叫匿名函数,即,函数没有具体的名称.先来看一个最简单例子: def f(x):return x**2print f(4) Python中使用lambda的话,写成这样 g = l ...

  6. ​ oracle分区表(附带按照月自动分区、按天自动分区)

    --list_range  示例   drop table list_range_tab purge; create table list_range_tab(n1 number,n2 date)pa ...

  7. PAT 1013 Battle Over Cities

    1013 Battle Over Cities (25 分)   It is vitally important to have all the cities connected by highway ...

  8. 通过cassandra-cli客户端了解cassandra的内部数据结构

    和cassandra数据库交互的方式有两种,一种是通过类似于cassandra-cli命令的thrift api,或者通过cassandra提供的cql(cassandra query lanugag ...

  9. 【LeetCode】数独

    判断一个数独是否合法,未填的空格用字符 ' . ' 表示.该数独有解并不是必要的. e.g. 如图合法数独,输入 ["53..7....","6..195..." ...

  10. 读取图片列表——CNN输入

    image_list = [] new_file_list = [] for root, _, file_list in os.walk(predict_dir): new_file_list += ...