package com.fizz.business.service.hanle;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.ThreadPoolExecutor;

@Configuration("coilTrackThreadPoolConfig")
public class CoilTrackThreadPoolConfig {

    @Bean("coilTrackExecutor")
    public ThreadPoolTaskExecutor coilTrackExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(10);               // 核心线程数
        executor.setMaxPoolSize(50);               // 最大线程数
        executor.setQueueCapacity(2000);           // 队列容量
        executor.setKeepAliveSeconds(60);          // 空闲线程存活时间
        executor.setThreadNamePrefix("CoilTrackPool-");
        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); // 队列满策略
        executor.initialize();
        return executor;
    }
}

