Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4514257

Thread.interrupt() on InputStream.read() fails

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 1.3.1
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      linux

      Description

      Name: gm110360 Date: 10/12/2001


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


      uname -a
      Linux <HOSTNAME> 2.4.3-20mdk #1 Sun Apr 15 23:03:10 CEST 2001 i686 unknown


      Thread.interrupt doesn't work for InputStream.read(). This is related to bug
      #4344135, but doesn't involve closing of an underlying socket.
      The program below shows that the thread cannot be interrupted.

      The program works fine under Solaris 8 Update 5 with JDK 1.3.1.



      import java.net.*;

      /** Tests Thread.interrupt() against InputStream.read() */
      public class test2 {

          static class SleeperThread extends Thread {
      public void run() {
      int c;
      try {
      c=System.in.read();
      }
      catch(Exception ex) {
      System.err.println("test2.SleeperThread.run(): " + ex);
      }
      }
          }

          
          public static void main(String[] args) {
      Thread thread;
      final long TIMEOUT=3000;

      thread=new SleeperThread();
      thread.start();
      System.out.println("test2.main(): sleeping for " + TIMEOUT + " msecs");
      try {thread.sleep(TIMEOUT);} catch(Exception e) {}
      System.out.println("test2.main(): sleeping -- done");

      System.out.println("test2.main(): interrupting thread");
      thread.interrupt();
      System.out.println("test2.main(): interrupting thread -- done");

      System.out.println("test2.main(): joining thread (timeout=" + TIMEOUT + "
      msecs)");
      try {thread.join(TIMEOUT);} catch(Exception e) {}
      System.out.println("test2.main(): joining thread -- done");

      System.out.println("test2.main(): thread.isAlive()=" + thread.isAlive());
      if(thread.isAlive()) {
      System.out.println("test2.main(): thread was interrupted but is still
      running !");
      }
          }
      }
      (Review ID: 133623)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                gmanwanisunw Girish Manwani (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: