eight
2024-12-10 f77fbfc8c07881f5239ce49b0dc78faaec3628b0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package cn.lihu.jh.module.ecg.config;
 
import cn.lihu.jh.module.ecg.service.queue.QueueService;
import cn.lihu.jh.module.ecg.service.room.RoomService;
import cn.lihu.jh.module.infra.api.config.ConfigApi;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
 
import javax.annotation.Resource;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
 
@Configuration
@EnableScheduling
public class DynamicSchedulingConfig implements SchedulingConfigurer {
 
    public static ScheduledTaskRegistrar static_scheduledTaskRegistrar;
 
    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        DynamicSchedulingConfig.static_scheduledTaskRegistrar = taskRegistrar;
 
        ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(1);
        scheduledThreadPoolExecutor.setRemoveOnCancelPolicy(true);
        taskRegistrar.setScheduler(scheduledThreadPoolExecutor);
    }
}