| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.example.kucoinclient.KucoinClientApplication; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.context.ConfigurableApplicationContext; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private ConfigurableApplicationContext context; |
| | | |
| | | @Scheduled(cron = "0 0/30 * * * ?") |
| | | @Autowired |
| | | @Qualifier("threadPoolTaskExecutor") |
| | | private ThreadPoolTaskExecutor threadPoolTaskExecutor; |
| | | |
| | | // @Scheduled(cron = "0 0/1 * * * ?") |
| | | public void restart() { |
| | | // 停止当前线程池中的任务 |
| | | threadPoolTaskExecutor.shutdown(); |
| | | // 创建新的线程池 |
| | | threadPoolTaskExecutor.initialize(); |
| | | |
| | | Thread restartThread = new Thread(() -> { |
| | | try { |
| | | SpringApplication.exit(context, () -> 0); |