| ||||
Copyright 1999 Sams Publishing |
|
Summary |
Blocked I/O statements can be troublesome to deal with, but this chapter offered a few techniques to avoid this difficulty. A blocked read() on an InputStream ignores interrupt() and stop() , but generally will throw an exception if its stream is closed by another thread. A blocked accept() on a ServerSocket also ignores interrupts, but will throw an exception if the ServerSocket is closed by another thread. |
ThreadedInputStream and BufferedThreadedInputStream provide a mechanism that allows a blocked read() to be interrupted and throw an InterruptedIOException . Although this technique comes with the overhead of another thread, it can be very useful by providing interruptible I/O. |
| |||
Toc |