スプリング・ピン


もっと読む
 applicationContext.xml   

id="threadPoolTaskExecutor"
class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">

name="corePoolSize" value="8" />

name="maxPoolSize" value="10" />

name="queueCapacity" value="200" />

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

name="rejectedExecutionHandler">

      
      
      
class="java.util.concurrent.ThreadPoolExecutor$AbortPolicy" />




    
ApplicationContext ac = new ClassPathXmlApplicationContext("config/spring/applicationContext-mini.xml");
ThreadPoolTaskExecutor threadPoolTaskExecutor=(ThreadPoolTaskExecutor)ac.getBean("threadPoolTaskExecutor");
for (int i = 1; i <= 11; i++) {
    String d= DateTimeUtil.getNowDate4();
System.out.println(" "+i+"       #"+d);
threadPoolTaskExecutor.execute(new Runnable() {
        public void run() {
            String d1= DateTimeUtil.getNowDate4();
//          
String msg= RedisUtil.lpop("test0714");
System.out.println("##########"+msg+"     ……"+d1);
            try {
                Thread.sleep(2000);
} catch (InterruptedException e) {
                e.printStackTrace();
}


        }
    });
}


corePoolSize、maxPoolSize、queueCapacity    

corePoolSize     ,               

maxPoolSize      ,               

queueCapacity      ,              

  :

corePoolSize=8;maxPoolSize=10;queueCapacity=20;
             
     40     
  threadPoolTaskExecutor.execute ,  8       ,  32    
queueCapacity   ,          20 ,             ,
    2        。
           =8+20+2=30   
 corePoolSize         ,  queueCapacity              
corePoolSize 。