Package jmri.util

Class ImmediatePipedOutputStream

All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

Makes a workaround for standard PipedOutputStream wait.

The PipedInputStream.read(), in case the receive buffer is empty at the time of the call, waits for up to 1000ms. PipedOutputStream.write(int) does call sink.receive, but does not notify() the sink object so that read's wait() terminates.

As a result, the read side of the pipe waits full 1000ms even though data become available during the wait.

The workaround is to simply PipedOutputStream.flush() after write, which returns from wait()s immediately.