ConcurrentTaskExecutor 有什么用

51 阅读1分钟

org.springframework.scheduling.concurrent.ConcurrentTaskExecutor 有什么用 为什么要使用ConcurrentTaskExecutor 封装一层 ThreadPoolTaskExecutor

    @Bean
    protected ConcurrentTaskExecutor getTaskExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(5);
        executor.setMaxPoolSize(10);
        executor.setQueueCapacity(100);
        executor.setKeepAliveSeconds(300);
        executor.setThreadNamePrefix("Executor-");
        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
        executor.initialize();
        return new ConcurrentTaskExecutor(executor);
    }