public String readLine(long wait){
  long start=System.currentTimeMillis();
  while (true) {
synchronized (list) {
      if (list.size() > 0) {
        return list.removeFirst();
      }
      try {
        list.wait(wait);
      }
 catch (      InterruptedException e) {
      }
      long time=System.currentTimeMillis() - start;
      if (time >= wait) {
        return null;
      }
    }
  }
}

public String readLine ( long wait ) { long start = System . currentTimeMillis ( ) ; while ( true ) { synchronized ( list ) { if ( list . size ( ) > 0 ) { return list . removeFirst ( ) ; } try { list . wait ( wait ) ; } catch ( InterruptedException e ) { } long time = System . currentTimeMillis ( ) - start ; if ( time >= wait ) { return null ; } } } }
read a line from the output .
