JDK-4291378 : Termination of thread blocked carrying out I/O - deprecation of stop method
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1999-11-15
  • Updated: 2001-07-19
  • Resolved: 2001-07-19
Related Reports
Relates :  
Description

Name: mc57594			Date: 11/15/99


java version "1.3beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
Java(TM) HotSpot Client VM (build 1.3beta-O, mixed mode)

There seems to be no way of stopping a thread that is blocking carrying out I/O
(for example connecting to a URL) - even by using interrupt, apart from calling
stop - which is now deprecated.

For example put the following in a thread run method and try to stop it:
        
        URL url;
        HttpURLConnection http;
        int rcode = 0;
        String rmesg = "";
        String urlTxt = "http://www.a-bad-link.com";
        url = new URL(urlTxt);
        http = (HttpURLConnection)url.openConnection();
        http.connect();
        rmesg = http.getResponseMessage();
        rcode = http.getResponseCode();
(Review ID: 97516) 
======================================================================

Comments
WORK AROUND Name: mc57594 Date: 11/15/99 None - except by using stop. ======================================================================
11-06-2004

EVALUATION It is my understanding that neither interrupt nor stop ever worked in this case. In fact, they work equally well for interrupting I/O (highly platform dependent). A much better way to interrupt a thread waiting on a socket (HttpURLConnection) is to close the socket. There are I/O improvements in progress. Perhaps they will address this problem more directly. joshua.bloch@Eng 1999-12-21 See the specification of the java.nio.channels.Channel interface. -- mr@eng 2001/7/18
21-12-1999