Review of solution for Cancelled Tasks

Jim Graham james.graham at oracle.com
Thu Jan 5 15:49:12 PST 2012


On 1/5/2012 1:21 PM, Roman Kennke wrote:
> In my experience, when you call Thread.interrupt() on a thread that is
> blocked in a network IO, it will not throw this exception. The only way
> to 'cancel' such IO is to close() the stream, which will result in an
> IOException in the blocked thread. I am not sure what this exception is
> actually used for. Some stuff I found in the web seems to indicate it's
> only used for PipedStreams:

I vaguely recall that this had to be changed because the only reliable 
cross platform way to nudge a thread out of a socket read was to close 
the socket.  Unfortunately, the method API contracts were all written 
such that the InterruptedIOException would return with the socket still 
open, so closing the socket wasn't a compatible option.

So, they had to back off from Interrupt working on all socket streams 
and introduce a new stream which had the contract that it would get the 
IIOE and it would be closed as a result.

But, back when the language was being modified to support interrupt() et 
al, the intention was that all IO operations would be interruptable in 
the same manner...

			...jim


More information about the openjfx-dev mailing list