import java.util.*;
public class Hi
{
public static void main(String args[]) throws java.io.IOException
{
TimerTask task = new TimerTask()
}
public void run()
{
System.out.println("Hi");
}
};
Timer timer = new Timer();
timer.schedule(task, 0, 500);
System.out.println("Press ENTER to stop");
System.in.read(new byte[10]);
timer.cancel();
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/