Spring Boot 定时器 conflict
发布时间
阅读量:
阅读量
Springboot框架中默认采用单线程机制处理定时任务,当多个线程在争夺资源时,若某一线程执行耗时较长,其余定时任务将被迫进入等待状态。随着等待时间的延长,未执行的定时任务数量将持续增加,进而可能引发系统性能的连锁反应,形成雪崩效应…
实际上,只需引入一个配置类并添加相应注解,即可有效解决这一问题。
package com.luding.diankan.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.ThreadPoolExecutor;
import org.springframework.scheduling.annotation.EnableAsync;
@Configuration
@EnableAsync
public cl
全部评论 (0)
还没有任何评论哟~
