code: private boolean monitorSlave(Process pr,
                                   BufferedReader input, BufferedReader error)
              throws IOException, InterruptedException {
  
          // flush the input buffer
          System.in.skip(System.in.available());
  
          // If the total amount of time allocated to the slave exceeds the maximum number of trials multiplied
          // by the maximum runtime plus some fudge factor the slave is declared as frozen
  
          boolean frozen = false;
  
          long startTime = System.currentTimeMillis();
          long lastAliveMessage = startTime;
          for(;;) {
              while( System.in.available() > 0 ) {
                  if( System.in.read() == 'q' ) {
                      System.out.println("User requested for the application to quit by pressing 'q'");
                      System.exit(0);
                  }
              }
  
              synchronized (streamLock) {
                  printBuffer(error, printErr);
              }
  
              if( input.ready() ) {
                  synchronized (streamLock) {
                      printBuffer(input, printOut);
                  }
              } else {
                  Thread.sleep(500);
              }
  
              try {
                  // exit value throws an exception is the process has yet to stop
                  pr.exitValue();
                  break;
              } catch( IllegalThreadStateException e) {
                  if( killRequested ) {
                      pr.destroy();
                      break;
                  }
                  // check to see if the process is frozen
                  if(frozenTime > 0 && System.currentTimeMillis() - startTime > frozenTime ) {
                      pr.destroy(); // kill the process
                      frozen = true;
                      break;
                  }
  
                  // let everyone know its still alive
                  if( System.currentTimeMillis() - lastAliveMessage > 60000 ) {
                      System.out.println("\nMaster is still alive: "+new Date()+"  Press 'q' and enter to quit.");
                      lastAliveMessage = System.currentTimeMillis();
                  }
              }
          }
  
          synchronized (streamLock) {
              printBuffer(error, printErr);
              printBuffer(input, printOut);
          }
  
          durationMilli = System.currentTimeMillis()-startTime;
          return !frozen && !killRequested;
      }
docs: Prints printOut the standard printOut and error from the slave and checks its health.  Exits if
  the slave has finished or is declared frozen.
  
  @return true if successful or false if it was forced to kill the slave because it was frozen