This is the mail archive of the java-discuss@sourceware.cygnus.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()


Jeff Sturm wrote:

> IOW, Sun crippled their API because Win32 doesn't handle interruptable
> I/O portably.  Not a good policy.
>
> Since Java doesn't support read() with timeouts either, it is easy to
> create a "stuck" thread that can never die.

Well, according to the JDK 1.2 API docs, it does for socket reads. We don't
implement this properly yet, though.

public void setSoTimeout(int timeout)
                  throws SocketException

... "With this option set to a non-zero timeout, a read() call on the
InputStream associated with this Socket will block for only this amount of
time. If the timeout expires, a java.io.InterruptedIOException is raised,
though the Socket is still valid. " ...

On the other hand, the behaviour of interrupt() was never well-specified.
Another way to unstick a blocked thread is to close the underlying socket
from another thread. Arguably, a good interrupt() implementation would be
better though.

regards

  [ bryce ]



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