仅供参考,没有去调。
public class CheckTime extends Thread {
   int time;
   boolean timeExpired = false;
   
   public CheckTime(int time) { // second
      this.time = time;
   }   public void run() {
     try{
       sleep(time*1000);
     }catch(Exception e){}
     timeExpired = true;
   }   public boolean expired() { return timeExpired;}
}class Testing {
   public static void main(String[] a) {
      CheckTime t = new CheckTime(3);
      t.start();
      while(!t.expired()) {
      // do your processing
      }
   }
}