package com.zanxiang.game.module.sdk.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

/**
 * @author : lingfeng
 * @time : 2024-05-27
 * @description : 异步线程池配置
 */
@Configuration
@EnableAsync
public class AsyncConfig implements AsyncConfigurer {

    @Override
    public Executor getAsyncExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        //设置核心线程数
        executor.setCorePoolSize(30);
        //设置最大线程数
        executor.setMaxPoolSize(50);
        //设置队列容量
        executor.setQueueCapacity(50);
        executor.initialize();
        return executor;
    }
}
