新版仿ok交易所-后端
1
zyy
2025-10-20 d6f1a81f8af23e55bcb2a44909efcfbf61cd34fe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.yami.trading.common.config;
 
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
 
@Component
public class ThreadPoolComponent {
    private ThreadPoolTaskExecutor executor;
 
    public ThreadPoolComponent() {
        executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(32); // 设置核心线程数
        executor.setMaxPoolSize(32); // 设置最大线程数
        executor.setQueueCapacity(10000); // 设置队列容量
        executor.setThreadNamePrefix("ThreadPoolComponent-"); // 设置线程名称前缀
        executor.initialize();
    }
 
    public ThreadPoolTaskExecutor getExecutor() {
        return executor;
    }
}