public static ExecutorService taskExecutor = Executors.newFixedThreadPool(5);
public static ExecutorService taskExecutor = new ThreadPoolExecutor(2, 5,
60L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>());
<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<!-- 核心线程数 ${task.core_pool_size}-->
<property name="corePoolSize" value="5" />
<!-- 最大线程数${task.max_pool_size}-->
<property name="maxPoolSize" value="10" />
<!-- 队列最大长度 ${task.queue_capacity}-->
<property name="queueCapacity" value="20" />
<!-- 线程池维护线程所允许的空闲时间,默认为60s ${task.keep_alive_seconds}-->
<property name="keepAliveSeconds" value="60" />
</bean>
线程池
发布时间 2023-03-23 10:47:33作者: 四海骄阳