package com.qaup.collision.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

/**
 * 自定义线程池，避免定时任务单线程阻塞的情况
 */
@Configuration
@EnableAsync  // 启用异步支持
public class SchedulerConfig {

    @Bean
    public ThreadPoolTaskScheduler taskScheduler() {
        ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
        // 设置线程池大小，根据需求调整
        scheduler.setPoolSize(3);
        // 设置线程名称前缀
        scheduler.setThreadNamePrefix("ScheduledTask-");
        return scheduler;
    }
}
