创新互联www.cdcxhl.cn八线动态BGP香港云服务器提供商,新人活动买多久送多久,划算不套路!

1. 定时任务实现方式
定时任务实现方式:
定时任务执行方式:
2. 创建定时任务
package com.autonavi.task.test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.autonavi.task.ScheduledTasks;
@Component
public class ScheduledTest {
private static final Logger logger = LoggerFactory.getLogger(ScheduledTasks.class);
@Scheduled(cron="0 0/2 * * * ?")
public void executeFileDownLoadTask() {
// 间隔2分钟,执行任务
Thread current = Thread.currentThread();
System.out.println("定时任务1:"+current.getId());
logger.info("ScheduledTest.executeFileDownLoadTask 定时任务1:"+current.getId()+ ",name:"+current.getName());
}
}