This is the mail archive of the
java-discuss@sources.redhat.com
mailing list for the Java project.
Re: Thread.interrupt
- To: Bryce McKinlay <bryce at albatross dot co dot nz>
- Subject: Re: Thread.interrupt
- From: Tom Tromey <tromey at redhat dot com>
- Date: 17 Jan 2001 13:14:00 -0700
- Cc: Java Discuss List <java-discuss at sourceware dot cygnus dot com>
- References: <87puhrdys1.fsf@creche.redhat.com> <3A60CA57.DE0AE0F7@albatross.co.nz>
- Reply-To: tromey at redhat dot com
>>>>> "Bryce" == Bryce McKinlay <bryce@albatross.co.nz> writes:
Bryce> Yes, I did that because it didn't work at the time, and I
Bryce> wasn't really sure of the exact semantics we need to implement
Bryce> for blocking I/O. I do think that it should go back in if we're
Bryce> reasonably sure it will work the way its supposed
Bryce> to. Compatibility with other unix implementations seems
Bryce> reasonable.
I looked at this a bit today. I tried the appended program, which I
think should cause the new thread to throw InterruptedIOException.
I ran it like this:
java intio | (sleep 10000; cat > /dev/null)
It prints "slept" and "interrupted" but the exception never comes.
This was with the JDK 1.2.2 on my x86 Linux box (RH 6.2).
Given that, I'm not too concerned about this problem any more. If you
can't rely on this working with the JDK then I doubt anybody relies on
it. I certainly wouldn't.
Things like this are annoying because Sun's insistence on not
fragmenting the platform apparently doesn't extend to their own
implementations...
Tom
public class intio extends Thread
{
public void run ()
{
try
{
for (int i = 0; i < 1000; ++i)
System.out.println (i);
}
catch (Throwable _)
{
System.err.println (_);
}
}
public intio ()
{
}
public static void main (String[] args)
{
try
{
Thread q = new intio ();
q.run ();
sleep (1000);
System.err.println ("slept");
q.interrupt ();
System.err.println ("interrupted");
q.join ();
}
catch (Throwable _)
{
System.err.println ("oops " + _);
}
}
}