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

Thread.sleep(millis, nanos) sleeps for incorrect time.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.0
    • hotspot
    • sparc
    • solaris_7

      With kestrel-rc1 the method sleep(millis, nanos) if the java.lang.Thread seems
      to sleeps a shorter periof of time then specified by parameters.
      For ex: thread with sleep(1000,1000) actually sleeps an about 970 millisec only with execution on 2 ways Ultra-2.

      With execution on the same machine but under JDK1.2.2 Solaris refs. the time is equal to 1010 millisec.

      The following simple test is passed on JDK1.2.2 and is failed with Kestrel.

      class test extends Thread {
          boolean done=true;
          long sleepTime=0;

          public void run() {
      long lTime=System.currentTimeMillis();
      try{sleep(1000,1000);}
      catch(Exception E){}
      sleepTime=System.currentTimeMillis()-lTime;
      done=true;
          }

          static void SleepTest() {
      test Th1=new test();
      Th1.start();
      try { Th1.join(); }
      catch (InterruptedException itr){ }
      System.out.println("Actual sleep time is " + Th1.sleepTime);
      if (Th1.sleepTime < 1000) {
      System.out.println("Test failed.");
      System.exit(1);
      }
          }

          public static void main(String arg[]) {
      test.SleepTest();
          }
      }

      konstantin.boudnik@eng 2000-02-16

            acorn Karen Kinnear (Inactive)
            kboudniksunw Konstantin Boudnik (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: