任务调度: Timer + TimerTask
package com.yunding.concurrent;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Timer;
import java.util.TimerTask;
/**
* 任务调度: Timer + TimerTask
* 高级用法: Spring + quartz
*
* @author beOkWithAnything
*
*/
public class TimeTest {
public static void main(String[] args) {
Timer timer = new Timer();
// 日历: Month 值是基于 0 的,例如,0 表示 1 月
Calendar c = new GregorianCalendar(2019, 05, 29, 23, 06, 30);
timer.schedule(new TimerTask() {
public void run() {
System.out.println("闹钟响,给老子xiang!!!");
}
}, c.getTime());
}
}