while(true){
    ..........
    if(符合){
        break;
    }
    ..........
    
    Thread.sleep(500);
    
}

解决方案 »

  1.   

    看你有没有必要新开一个线程还是直接在主线程中完成。
    class T extends Thread{
        public void run(){
            while(true){
            ..........
            if(符合){
                break;
            }
            ..........
        
            Thread.sleep(500);
        
            }
        }
    }Thread t=new T();
    t.start();完整程序自己拼凑吧。
      

  2.   

    你直接用SQL语句查询不就完了,还用一条一条查
      

  3.   

    public void run(){  //reload this method
       //part of your method
       try{
         
           Thread.sleep(//how long will you sleep);
       }
      catch(InterruptedException e){//handling code}
    以上就是使用方法,给你一个例子:public void run(){    if(name=="fishstudio")    try{
          Thread.sleep(1000);//毫秒     }
       catch(InterruptException e){ System.out.println("懒得理你");}    System.out.println("醒了");
    }
      

  4.   

    public void run(){
            while(true)
            {
                try
                {
                    处理函数1() 
                    类.sleep(1000);//这个类应该是各Thread
                    处理函数2();         }catch(Exception e){
         e.printStackTrace();
             }
            }
        }
      

  5.   

    用Timer挺简单的。
    import javax.swing.Timer;
    方法里这么写:
    Timer ti = new Timer(等待的时间,new SDB());
    那个SDB类要implements ActionListener
    然后覆盖方法:
    public void actionPerformed(ActionEvent e){
        //这里写查询语句
    }
    他就每隔“等待的时间”查一次。
    查到后想退出的话加个标志变量就行了。