This is the mail archive of the java-discuss@sources.redhat.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Thread.interrupt


>>>>> "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 " + _);
      }
  }
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]