spring 线程池 的一个坑。

问题简述:

配置的队列初始化的消费者线程占满了线程池。导致其他的再使用此线程池中线程不运行。不报错,不抛异常。线程的数量仅为为线程池的配置中的最小值。

<task:executor pool-size="100-150" queue-capacity="250" >

同时schema描述中写道:

The size of the executor‘s thread pool as either a single value or a range
    (e.g. 5-10). If no bounded queue-capacity value is provided, then a max value
    has no effect unless the range is specified as 0-n. In that case
, the core pool
    will have a size of n, but the ‘allowCoreThreadTimeout‘ flag will be set to true.
    If a queue-capacity is provided, then the lower bound of a range will map to the
    core size and the upper bound will map to the max size. If this attribute is not
    provided, the default core size will be 1, and the default max size will be
    Integer.MAX_VALUE (i.e. unbounded).
   。。。。。

后来解决办法:赶紧调大了线程池的数量。

spring 版本:3.2.8

时间: 2024-08-05 11:14:00

spring 线程池 的一个坑。的相关文章

Spring线程池开发实战

Spring线程池开发实战 作者:chszs,转载需注明. 作者博客主页:http://blog.csdn.net/chszs 本文提供了三个Spring多线程开发的例子,由浅入深,由于例子一目了然,所以并未做过多的解释.诸位一看便知. 前提条件: 1)在Eclipse创建一个Java项目,我取名为SpringThreadDemo.2)项目所需的JAR包如图所示:  下面开始. 注:项目源码已经托管到GitHub,地址:https://github.com/chszs/SpringThreadD

java和spring 线程池总结

1. spring 的线程池 ThreadPoolTaskExecutor @Configuration public class ThreadPoolConfig { @Bean("threadPoolTaskExecutor") public ThreadPoolTaskExecutor threadPoolTaskExecutor(){ ThreadPoolTaskExecutor threadPoolTaskExecutor=new ThreadPoolTaskExecutor

Spring线程池开发实战及使用spring注解

本文提供了三个Spring多线程开发的例子,由浅入深,由于例子一目了然,所以并未做过多的解释.诸位一看便知. 前提条件: 1)在Eclipse创建一个Java项目,我取名为SpringThreadDemo.2)项目所需的JAR包如图所示:  下面开始. 注:项目源码已经托管到GitHub,地址:https://github.com/chszs/SpringThreadDemo 例子1:Spring结合Java线程. 通过继承Thread创建一个简单的Java线程,然后使用@Component让S

spring线程池配置

源自:http://zjriso.iteye.com/blog/771706 1.了解 TaskExecutor接口 Spring的TaskExecutor接口等同于java.util.concurrent.Executor接口. 实际上,它存在的主要原因是为了在使用线程池的时候,将对Java 5的依赖抽象出来. 这个接口只有一个方法execute(Runnable task),它根据线程池的语义和配置,来接受一个执行任务.最初创建TaskExecutor是为了在需要时给其他Spring组件提供

spring线程池ThreadPoolTaskExecutor与阻塞队列BlockingQueue

一: ThreadPoolTaskExecutor是一个spring的线程池技术,查看代码可以看到这样一个字段: private ThreadPoolExecutor threadPoolExecutor; 可以发现,spring的  ThreadPoolTaskExecutor是使用的jdk中的java.util.concurrent.ThreadPoolExecutor进行实现, 直接看代码: @Override protected ExecutorService initializeExe

转载:C++线程池的一个实现

原文转自:http://www.cnblogs.com/lidabo/p/3328646.html 略有修改 Cthread类参见:http://www.cnblogs.com/tangxin-blog/p/4835211.html CThreadPool.h 1 #ifndef __MY_THREAD_POOL_H_ 2 #define __MY_THREAD_POOL_H_ 3 4 #include "CThread.h" 5 #include <set> 6 #inc

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.spring

线程池-实现一个取消选项

代码Demo: using System;using System.Threading; 在Main方法下面加入以下代码片段: static void AsyncOperation1(CancellationToken token) { Console.WriteLine("Starting the first task"); for (int i = 0; i < 5; i++) { if (token.IsCancellationRequested) { Console.Wr

spring 线程池执行器DefaultManagedTaskScheduler之jndi

package com.example.spring.async.config; import java.util.concurrent.Executors; import javax.naming.NamingException; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springf