| File was renamed from websocketClient/src/main/java/org/example/config/AsyncConfiguration.java |
| | |
| | | package org.example.config; |
| | | package org.example.ThreadConfig; |
| | | |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | |
| | | @Bean(name = "threadPoolTaskExecutor") |
| | | public ThreadPoolTaskExecutor threadPoolTaskExecutor() { |
| | | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); |
| | | executor.setCorePoolSize(50); // 核心线程数 |
| | | executor.setMaxPoolSize(100); // 最大线程数 |
| | | executor.setQueueCapacity(300); // 队列容量 |
| | | executor.setCorePoolSize(400); // 核心线程数 |
| | | executor.setMaxPoolSize(1200); // 最大线程数 |
| | | executor.setQueueCapacity(1500); // 队列容量 |
| | | executor.setKeepAliveSeconds(60); // 线程空闲时的存活时间为60秒 |
| | | executor.setThreadNamePrefix("MyThread-"); // 线程名称的前缀 |
| | | executor.setThreadNamePrefix("MexcThread-"); // 线程名称的前缀 |
| | | executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); // 使用 CallerRunsPolicy 拒绝策略 |
| | | return executor; |
| | | } |