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

fp.bugs 2914 Win32 only: Thread.isAlive() doesn't really return true

XMLWordPrintable

    • 1.0.2
    • x86
    • windows_nt
    • Verified

      ###@###.### (MR DUANE E TIEMANN)

      Win32 only: Thread.isAlive() does not return boolean true, it returns a non-falsep value.
      Therefore Thread.isAlive() == true always returns false.

      Steps to reproduce:
      Compile and run the attached code.

      import java.io.*;

      public class ThreadAliveTest
      {
          public static void main(String args[])
          {
             task theTask = new task();
        
             theTask.start();

             boolean result;

             result = theTask.isAlive();

             System.out.println("result is supposedly " + result);

             if (result == false)
                System.out.println("result is false");
             else
                System.out.println("result is not false");

             if (result == true)
                System.out.println("result is true");
             else
                System.out.println("result is not true");
          
             if (result)
                System.out.println("result is close enough to true");
             else
                System.out.println("result is not close enough to true");

             theTask.stop();
             try
             {
                theTask.join();
             }
             catch (InterruptedException e) {}
          }
      }


      class task extends Thread
      {
          public void run()
          {
             while (true);
          }
      }


            dconnellsunw David Connelly (Inactive)
            kasmithsunw Kevin Smith (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: