InterruptedIOException
Some methods of various I/O classes
will throw an InterruptedIOException in response to the
interrupt()
method: if the target thread was
blocked on an I/O operation, then the InterruptedIOException will be
thrown. On green-thread implementations, this is implemented
incompletely: some I/O methods are interruptible and some are not.
This feature is not implemented at all on Windows. On Solaris
native-thread virtual machines, this is implemented somewhat
inconsistently: in Java 1.1, some operations will throw a standard
exception (e.g., SocketException), and in Java 2 they will throw an
InterruptedIOException.
In the future, this implementation will be consistent, but it is unclear what direction that will take, and it’s possible that this exception will be deprecated. In the meantime, developers who need to interrupt I/O should close the stream on which the I/O is being performed, and interrupted I/O should not be considered restartable, even on platforms that support it.
Get Java Threads, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.