import java.util.Timer;
import java.util.TimerTask;
/*使用TimerTask进行调度*/
class MyTask extends TimerTask{
public void run(){
System.out.println("任务执行。。。");
}
}
public class TimeTaskDemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
Timer t = new Timer();
MyTask mytask = new MyTask();
t.schedule(mytask, 1000, 3000); //任务1s后执行,每个3秒重复执行
}
}
import java.util.TimerTask;
/*使用TimerTask进行调度*/
class MyTask extends TimerTask{
public void run(){
System.out.println("任务执行。。。");
}
}
public class TimeTaskDemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
Timer t = new Timer();
MyTask mytask = new MyTask();
t.schedule(mytask, 1000, 3000); //任务1s后执行,每个3秒重复执行
}
}