void () { if (myReader == null) return; final Runnable runnable = new Runnable() { @Override public void run() { if (myRunning) { try { myReader = updateReaderIfNeeded(myReader); int i = 0; while (i++ < 1000) { final BufferedReader reader = myReader; if (myRunning && reader != null && reader.ready()) { addMessage(reader.readLine()); } else { break; } } } catch (IOException e) { LOG.info(e); addMessage("I/O Error" + (e.getMessage() != null ? ": " + e.getMessage() : "")); return; } } if (myAlarm.isDisposed()) return; myAlarm.addRequest(this, 100); } }; if (myAlarm.isDisposed()) return; myAlarm.addRequest(runnable, 10); }