Does spring @Scheduled annotated methods runs on different threads?

前端 未结 8 2321
时光取名叫无心
时光取名叫无心 2020-11-30 01:19

I have several methods annotated with @Scheduled(fixedDelay=10000).

In the application context, I have this annotation-driven setup:

<         


        
8条回答
  •  醉梦人生
    2020-11-30 01:22

    For completeness, code below shows the simplest possible way to configure scheduler with java config:

    @Configuration
    @EnableScheduling
    public class SpringConfiguration {
    
        @Bean(destroyMethod = "shutdown")
        public Executor taskScheduler() {
            return Executors.newScheduledThreadPool(5);
        }
        ...
    

    When more control is desired, a @Configuration class may implement SchedulingConfigurer.

提交回复
热议问题