import java.util.*;
public class YourTimer
{
Timer timer=new Timer();
YourTask task=new YourTask();
public YourTimer()
{
Date date=new Date();
timer.schedule(task,5000,10000);//将在5秒钟后执行task中的run(),每10秒执行一次
}
public static void main(String[] args)
{
YourTimer yourTimer1 = new YourTimer();
}
public class YourTask extends TimerTask
{
public void run()
{
System.out.println("执行了一次");
}
}
}