public void run(){
  while (m_keyboardStream != null) {
    try {
      if (m_keyboardReadRequest) {
        String s=m_keyboardStream.readLine();
        m_keyboardInput.add(s);
        m_keyboardReadRequest=false;
synchronized (this) {
          notifyAll();
        }
      }
 else       try {
        Thread.sleep(50);
      }
 catch (      InterruptedException ie) {
      }
    }
 catch (    IOException io) {
    }
  }
}

public void run ( ) { while ( m_keyboardStream != null ) { try { if ( m_keyboardReadRequest ) { String s = m_keyboardStream . readLine ( ) ; m_keyboardInput . add ( s ) ; m_keyboardReadRequest = false ; synchronized ( this ) { notifyAll ( ) ; } } else try { Thread . sleep ( 50 ) ; } catch ( InterruptedException ie ) { } } catch ( IOException io ) { } } }
a seperate thread collects our input so that we can block in the docontinue on the main thread and then allow the user to interrupt us via keyboard input on this thread . < p / > we built the stupid thing in this manner , since readline ( ) will block no matter what and if we ' quit ' we can ' t seem to kill this thread . . close ( ) doesn ' t work and thread . stop ( ) , etc . all fail to do the job . < p / > thus we needed to take a request response approach so that we only block when requested to do so .
