to hellomartin(小白狼):
这样的效率是不是有点...,有点像汇编时代了

解决方案 »

  1.   

    public synchronized void run() {
        while(!stop) {
            System.out.println("ok");        
            try {
                wait(2000);
            } catch(InterruptedException e) {
                System.err.println("Interrupted");
            }
        }
    }
      

  2.   

    If yours is a single thread, it is easy.Thread.currentThread().sleep(1000);
      

  3.   

    Thread.sleep(long [,int]);
    进行设置等待的时间
      

  4.   

    可以看看线程的讲解啊,java有提供这样的方法.
      

  5.   

    Anywhere in a method regardless whether the class is a Thread/Runnable or not:try{
       Thread.sleep(1000);//1000ms = 1sec
    }catch(InterruptedException e){
    }
      

  6.   

    在线程中使用sleep 语句就可以呀