zoukankan      html  css  js  c++  java
  • 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>  

  • 相关阅读:
    Codeforces Round #277 (Div. 2)
    Topcoder SRM 637 (Div.2)
    【转】大素数判断和素因子分解【miller-rabin和Pollard_rho算法】
    【网络流#5】UVA 11082 最大流
    【网络流#4】UVA 753 最大流
    Codeforces Round #274 (Div. 2)
    【网络流#3】hdu 1532
    【网络流#2】hdu 1533
    【网络流#1】hdu 3549
    Codeforces Round #273 (Div. 2)
  • 原文地址:https://www.cnblogs.com/shoshana-kong/p/8976022.html
Copyright © 2011-2022 走看看