liusuyi
2026-06-11 b097f7539a7429a85cdda7959c9ecb83a37a2918
ard-framework/src/main/java/com/ard/framework/config/ThreadPoolConfig.java
@@ -4,6 +4,7 @@
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
@@ -12,7 +13,7 @@
/**
 * 线程池配置
 *
 * @author ruoyi
 * @author ard
 **/
@Configuration
public class ThreadPoolConfig
@@ -30,6 +31,7 @@
    private int keepAliveSeconds = 300;
    @Bean(name = "threadPoolTaskExecutor")
    @Primary
    public ThreadPoolTaskExecutor threadPoolTaskExecutor()
    {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
@@ -60,4 +62,32 @@
            }
        };
    }
    @Bean("mediaVideoExecutor")
    public ThreadPoolTaskExecutor mediaVideoExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(10);    // 核心线程数:同时处理视频的核心线程数
        executor.setMaxPoolSize(10);     // 最大线程数:线程池不会扩展超过这个数量
        executor.setQueueCapacity(50);   // 队列容量:等待执行的任务数量,之前20太小可能会拒绝任务
        executor.setThreadNamePrefix("media-video-");
        // 当线程池和队列都满时的拒绝策略
        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
        executor.initialize();
        return executor;
    }
    @Bean("mediaPicExecutor")
    public ThreadPoolTaskExecutor mediaPicExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(10);    // 核心线程数:同时处理视频的核心线程数
        executor.setMaxPoolSize(10);     // 最大线程数:线程池不会扩展超过这个数量
        executor.setQueueCapacity(50);   // 队列容量:等待执行的任务数量,之前20太小可能会拒绝任务
        executor.setThreadNamePrefix("media-pic-");
        // 当线程池和队列都满时的拒绝策略
        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
        executor.initialize();
        return executor;
    }
}