开始输出一段"hello",然后时间检测或者说时间走了5秒, 然后在输出"hello".不是sleep,而是时间方面的函数,时间也在走。

解决方案 »

  1.   

    import java.util.TimerTask;
    import java.util.Timer;public class Timertasktest
    {
    public static void main(String[] args)
    {
    Timer timer = new Timer();
    timer.schedule(new TimerTask()
    {
    public void run()
    {
    System.out.println("hello");
    }
    }, 0, 5000);
    }
    }
      

  2.   

    路过来看看,但还是有些不懂得地方啊,
    timer.schedule(new TimerTask()
    {
    public void run()
    {
    System.out.println("hello");
    }
    }, 0, 5000);
    由于是新手,还请不要见笑阿,这个跟C++ 中的SetTimer()有什么区别阿