package com.zy.asrs.task;
|
|
import com.core.common.DateUtils;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import java.util.Date;
|
|
/**
|
* Created by vincent on 2020/6/30
|
*/
|
//@Component
|
public class TestScheduler {
|
|
private static final Logger logger = LoggerFactory.getLogger(TestScheduler.class);
|
|
@Scheduled(cron = "0/3 * * * * ? ")
|
@Async
|
public void test() throws InterruptedException {
|
while (true) {
|
//模拟耗时任务,阻塞10s
|
Thread.sleep(10000);
|
break;
|
}
|
}
|
|
@Scheduled(cron = "0/3 * * * * ? ")
|
@Async
|
public void test1() throws InterruptedException {
|
System.out.println(DateUtils.convert(new Date()));
|
}
|
|
}
|