@Component
@EnableScheduling   // 1.开启定时任务
@EnableAsync        // 2.开启多线程
public class MultithreadScheduleTask {
          @Async
          @Scheduled(fixedRate= 3000) //3秒执行一次
          public void first() throws InterruptedException {
                System.out.println("第一个定时任务开始 : " + LocalDateTime.now().toLocalTime() + "\r\n线程 : " + Thread.currentThread().getName());
                System.out.println();
                Thread.sleep(1000 * 10);
          }

          @Async
          @Scheduled(fixedRate = 2000)
          public void second() {
                System.out.println("第二个定时任务开始 : " + LocalDateTime.now().toLocalTime() + "\r\n线程 : " + Thread.currentThread().getName());
                System.out.println();
          }
    }