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

wait does not wait for notify

XMLWordPrintable

    • sol-beta2
    • generic, sparc
    • generic, solaris_7



      Name: dkR10031 Date: 06/19/2000


      HotSpot Kestrel Solaris 1.3.0beta2-b19 (Solaris) fails the test
      nsk/regression/b4193564 from testbase_nsk.
      wait(Long.MAX_VALUE - 1L) does not wait for notify.
      Kestrel win32 1.3.0fcs passes the test.

      Log and test source follow:

      $ java -version
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-b19)
      Java HotSpot(TM) Server VM (build 1.3-internal, mixed mode)

      $ /export/ld24/java/hotspot/Solaris_JDK_1.3/bin/java b4193564
      Test FAILED, st == 0

      ------------------------------------------------------------------ b4193564.java
      // File: @(#)b4193564.java 1.1 99/06/28
      // Copyright 06/28/99 Sun Microsystems, Inc. All Rights Reserved

      import java.io.PrintStream;

      public class b4193564 {

          public static void main(String argv[]) {
      System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
          }

          public static int run(String args[], PrintStream out) {
      b4193564 test = new b4193564();
           boolean ok = test.Object0035();
      return (ok ? 0/*STATUS_PASSED*/ : 2/*STATUS_FAILED*/);
          }

          public boolean Object0035() {
      int st = 0;
      b4193564_wait o = new b4193564_wait( System.out, 5000 );
      o.start();
          
      try {
      st = o.getState(Long.MAX_VALUE - 1L);
      } catch(InterruptedException e) {
      System.out.println( "Another thread has interrupted" );
      return true;
      }

      if (st == 12) {
      System.out.println("Test passed");
      } else {
      System.out.println("Test FAILED, st == " + st);
      }
      return st == 12;
          }
      }

      class b4193564_wait extends Thread {
          private int state = 0;
          private long sleepTime = 0;
          private PrintStream out;
        
          public b4193564_wait( PrintStream out, long sleepTime ) {
      this.sleepTime = sleepTime;
      this.out = out;
          }
        
          public synchronized void setState( int i ) {
      state = i;
      notify();
          }
        
          public synchronized int getState(long waitTime) throws InterruptedException {
      wait( waitTime );
      return state;
          }
        
          public void run() {
      try {
      sleep( sleepTime );
      } catch( InterruptedException e ) {}
      setState( 12 );
          }
      }

      ======================================================================

            kbr Kenneth Russell (Inactive)
            dimasunw Dima Dima (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: