From 5d901b5e3f033e8b04e53420d68626cbd87431c8 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期五, 06 五月 2022 10:12:34 +0800 Subject: [PATCH] 使用阿里代码规范。规范代码写法 --- src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java index 1dfd591..71aed27 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java @@ -7,9 +7,15 @@ import java.util.concurrent.ThreadPoolExecutor; +/** + * ThreadPoolTask 閰嶇疆绫� + * @author lin + */ @Configuration @EnableAsync(proxyTargetClass = true) public class ThreadPoolTaskConfig { + + public static final int cpuNum = Runtime.getRuntime().availableProcessors(); /** * 榛樿鎯呭喌涓嬶紝鍦ㄥ垱寤轰簡绾跨▼姹犲悗锛岀嚎绋嬫睜涓殑绾跨▼鏁颁负0锛屽綋鏈変换鍔℃潵涔嬪悗锛屽氨浼氬垱寤轰竴涓嚎绋嬪幓鎵ц浠诲姟锛� @@ -20,11 +26,11 @@ /** * 鏍稿績绾跨▼鏁帮紙榛樿绾跨▼鏁帮級 */ - private static final int corePoolSize = 5; + private static final int corePoolSize = cpuNum; /** * 鏈�澶х嚎绋嬫暟 */ - private static final int maxPoolSize = 30; + private static final int maxPoolSize = cpuNum*2; /** * 鍏佽绾跨▼绌洪棽鏃堕棿锛堝崟浣嶏細榛樿涓虹锛� */ @@ -32,12 +38,16 @@ /** * 缂撳啿闃熷垪澶у皬 */ - private static final int queueCapacity = 10000; + private static final int queueCapacity = 500; /** * 绾跨▼姹犲悕鍓嶇紑 */ - private static final String threadNamePrefix = "wvp-sip-handle-"; + private static final String threadNamePrefix = "wvp-"; + /** + * + * @return + */ @Bean("taskExecutor") // bean鐨勫悕绉帮紝榛樿涓洪瀛楁瘝灏忓啓鐨勬柟娉曞悕 public ThreadPoolTaskExecutor taskExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); -- Gitblit v1.8.0