소스 검색

1. 优化线程池参数,将队列大小设置为可调整

liukx 4 년 전
부모
커밋
35f177875a
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      elab-spring/src/main/java/com/elab/spring/utils/ThreadProcessUtils.java

+ 2 - 2
elab-spring/src/main/java/com/elab/spring/utils/ThreadProcessUtils.java

@@ -172,11 +172,11 @@ public class ThreadProcessUtils implements ApplicationContextAware, Initializing
         this.threadProperties = this.applicationContext.getBean(ThreadProperties.class);
         if (this.threadProperties != null && this.threadProperties.getThreadPool() != null) {
             ThreadPoolProperties threadPool = this.threadProperties.getThreadPool();
-            ExecutorService executorService = new ThreadPoolExecutor(threadPool.getCorePoolSize(), threadPool.getMaximumPoolSize(), threadPool.getKeepAliveTime(), TimeUnit.SECONDS, new ArrayBlockingQueue(100));
+            ExecutorService executorService = new ThreadPoolExecutor(threadPool.getCorePoolSize(), threadPool.getMaximumPoolSize(), threadPool.getKeepAliveTime(), TimeUnit.SECONDS, new ArrayBlockingQueue(threadPool.getQueueSize()));
             setExecutorService(executorService);
         } else {
             ThreadPoolProperties threadPool = new ThreadPoolProperties();
-            ExecutorService executorService = new ThreadPoolExecutor(threadPool.getCorePoolSize(), threadPool.getMaximumPoolSize(), threadPool.getKeepAliveTime(), TimeUnit.SECONDS, new ArrayBlockingQueue(100));
+            ExecutorService executorService = new ThreadPoolExecutor(threadPool.getCorePoolSize(), threadPool.getMaximumPoolSize(), threadPool.getKeepAliveTime(), TimeUnit.SECONDS, new ArrayBlockingQueue(threadPool.getQueueSize()));
             setExecutorService(executorService);
         }
     }