package com.mini.capi.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.concurrent.*;

@Configuration
public class ThreadPoolConfig {

    /**
     * 附件处理线程池：核心线程2，最大线程5，队列100，空闲60s回收
     */
    @Bean("attachmentThreadPool")
    public ExecutorService attachmentThreadPool() {
        return new ThreadPoolExecutor(
                2,
                5,
                60L,
                TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(100),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy() // 队列满时拒绝策略（可根据需求调整）
        );
    }
}
