public int read(int timeout) throws IOException { if ((reader == null) || !reader.isAlive()) reader = new Reader(); try { reader.join(timeout); } catch (InterruptedException e) { throw new IOException("read was interrupted", e); } handleException(); if (read == null) throw new TimeoutException(); return read; }
@Override public boolean isRunning() { return reader.isAlive() && !close.isSet(); }