void () { try { setClosed(false); while (true) { final boolean read = readAvailable(); if (myRemoteProcess.isDisconnected()) { myReader.close(); break; } if (isStopped) { break; } Thread.sleep(mySleepingPolicy.getTimeToSleep(read)); // give other threads a chance } } catch (InterruptedException ignore) { } catch (Exception e) { LOG.warn(e); } finally { setClosed(true); } }