新版仿ok交易所-后端
1
zyy
2026-03-05 9fa09b7700040b6cf416081ba0edfcfb72219b16
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;
    }
}