如視頻導入文件和路徑
成都創(chuàng)新互聯(lián)公司堅持“要么做到,要么別承諾”的工作理念,服務領(lǐng)域包括:成都網(wǎng)站建設、成都做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣等服務,滿足客戶于互聯(lián)網(wǎng)時代的達孜網(wǎng)站設計、移動媒體設計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡建設合作伙伴!
package quartz;
import java.util.Date;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
public class HelloJob implements Job {
public HelloJob() {
}
public void execute(JobExecutionContext context)
throws JobExecutionException {
System.out.println("---start---");
System.out.println("Hello World! - " + new Date());
System.out.println("---end---");
}
}
第二個class
package quartz;
import static org.quartz.JobBuilder.newJob;
import static org.quartz.TriggerBuilder.newTrigger;
import static org.quartz.DateBuilder.evenSecondDateAfterNow;
import java.util.Date;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerFactory;
import org.quartz.Trigger;
import org.quartz.impl.StdSchedulerFactory;
/*
quarz
*/
public class SimpleExample {
public void run() throws Exception {
//1、創(chuàng)建Scheduler的工廠
SchedulerFactory sf = new StdSchedulerFactory();
//2、從工廠中獲取調(diào)度器
Scheduler sched = sf.getScheduler();
//3、創(chuàng)建JobDetail
JobDetail job = newJob(HelloJob.class).withIdentity("job1", "group1").build();
//時間,下一秒
Date runTime = evenSecondDateAfterNow();
//4、觸發(fā)器
Trigger trigger = newTrigger().withIdentity("trigger1", "group1").startAt(runTime).build();
//5、注冊任務和觸發(fā)條件
sched.scheduleJob(job, trigger);
//6、啟動
sched.start();
try {
// 5秒后停止
Thread.sleep(5L*1000L);
// executing...
} catch (Exception e) {
//
}
sched.shutdown(true);
}
public static void main(String[] args) throws Exception {
SimpleExample example = new SimpleExample();
example.run();
}
}