Spring线程池的5个要素

<?xml version="1.0" encoding="UTF-8"?>  

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "/spring-beans.dtd">  

<beans>  

<!-- 异步线程池 -->  

<bean id="threadPool" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">  

<!-- 核心线程数  -->  

<property name="corePoolSize" value="10" />  

<!-- 最大线程数 -->  

<property name="maxPoolSize" value="50" />  

<!-- 队列最大长度 >=mainExecutor.maxSize -->  

<property name="queueCapacity" value="1000" />  

<!-- 线程池维护线程所允许的空闲时间 -->  

<property name="keepAliveSeconds" value="300" />  

<!-- 线程池对拒绝任务(无线程可用)的处理策略 -->  

<property name="rejectedExecutionHandler">  

<bean class="java.util.concurrent.ThreadPoolExecutor$CallerRunsPolicy" />  

</property>  

</bean>  

<bean id="mainExecutor" class="supben.MainExecutor">  

<property name="threadPool" ref="threadPool" />   

</bean>  

<bean id="springScheduleExecutorTask" class="org.springframework.scheduling.concurrent.ScheduledExecutorTask">  

<property name="runnable" ref="mainExecutor" />  

<!-- 容器加载10秒后开始执行 -->  

<property name="delay" value="10000" />  

<!-- 每次任务间隔 5秒-->  

<property name="period" value="5000" />  

</bean>  

<bean id="springScheduledExecutorFactoryBean" class="org.springframework.scheduling.concurrent.ScheduledExecutorFactoryBean">  

<property name="scheduledExecutorTasks">  

<list>  

<ref bean="springScheduleExecutorTask" />  

</list>  

</property>  

</bean>  

</beans>  

 

 

 

 

 

 

 

 

 

posted on 2018-05-01 12:46  shoshana~ 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/shoshana-kong/p/8976022.html

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值