阅读(1277) (1)

任务调度

2019-07-07 22:16:38 更新
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;


public class MyThread{
    public static void main(String[] args) throws InterruptedException {
        //一秒后每隔200毫秒打印一次hello...
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("hello...");
            }
        }, new Date(System.currentTimeMillis()+1000), 200);
    }
}