This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Unblocking blocked I/O
David Vrabel wrote:
>I have a thread which blocks while reading from a network Socket. I need
>to unblock the thread so it can see it's supposed to die (and then die
>gracefully).
>
>A search of the internet suggests that I can close the Socket (from
>another thread) and then the blocked read will throw an exception (and
>hence become unblocked). This does not work. The thread remains blocked
>on the read.
>
>I also tried Thread.interrupt() but that seemed completely broken.
>
This discussion has come up before. Last time, I think we agreed that
the semantics of Thread.interrupt() were pretty much undefined when it
comes to blocking I/O, and since its implementation varies significantly
between platforms we wern't going to bother implementing it at all
unless Sun fix it or clarify the spec.
Unblocking I/O by closing a socket (resource revocation), however,
should work, and its a bug if it doesn't. Do you have a test case?
regards
Bryce.