Tue Mar 14 14:16:00 GMT 2000
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)
... "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
[ bryce ]
More information about the Java