applicationContext-thread.xml 1.1 KB

1234567891011121314151617181920212223
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://www.springframework.org/schema/beans
  5. http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
  6. <!-- 异步线程池 -->
  7. <bean id="threadPool" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
  8. <!-- 核心线程数 -->
  9. <property name="corePoolSize" value="10"/>
  10. <!-- 最大线程数 -->
  11. <property name="maxPoolSize" value="20"/>
  12. <!-- 队列最大长度 >=mainExecutor.maxSize -->
  13. <property name="queueCapacity" value="1000"/>
  14. <!-- 线程池维护线程所允许的空闲时间 -->
  15. <property name="keepAliveSeconds" value="300"/>
  16. <!-- 线程池对拒绝任务(无线程可用)的处理策略 -->
  17. <property name="rejectedExecutionHandler">
  18. <bean class="java.util.concurrent.ThreadPoolExecutor$CallerRunsPolicy"/>
  19. </property>
  20. </bean>
  21. </beans>