R
Rogan Dawes
Hi folks,
While trying to figure out a solution to the "read console with timeout"
problem posed on this group, I encountered an interesting situation.
I have one thread blocking in a readLine() on a Reader (a BufferedReader
wrapping an InputStreamReader wrapping System.in).
In another thread, I close the reader, expecting the blocking readLine()
to throw an exception. But it didn't.
Would it not make sense for a blocking read to throw an exception if the
stream/reader is closed while the read is blocking? I guess one can just
say "don't access the reader from multiple threads", like the Swing EDT
rule, but it seems a bit arbitrary in this case.
Regards,
Rogan
While trying to figure out a solution to the "read console with timeout"
problem posed on this group, I encountered an interesting situation.
I have one thread blocking in a readLine() on a Reader (a BufferedReader
wrapping an InputStreamReader wrapping System.in).
In another thread, I close the reader, expecting the blocking readLine()
to throw an exception. But it didn't.
Would it not make sense for a blocking read to throw an exception if the
stream/reader is closed while the read is blocking? I guess one can just
say "don't access the reader from multiple threads", like the Swing EDT
rule, but it seems a bit arbitrary in this case.
Regards,
Rogan