JDK-4814012 : System clock acceleration on Windows still exists
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 1.3.1,1.4.0,1.4.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000,windows_xp
  • CPU: x86
  • Submitted: 2003-02-06
  • Updated: 2003-02-12
  • Resolved: 2003-02-12
Related Reports
Duplicate :  
Description

Name: gm110360			Date: 02/06/2003


FULL PRODUCT VERSION :
All versions 1.3.1 through 1.4.1

FULL OPERATING SYSTEM VERSION : Microsoft Windows XP
[Version 5.1.2600]


ADDITIONAL OPERATING SYSTEMS : Windows 2000



A DESCRIPTION OF THE PROBLEM :
  Using the test code in that bug report, I was able to reproduce
the time acceleration in many, though not all, of our XP and
2000 machines.  It is not clear what the features are of the
machines where it cannot be reproduced, except possibly that
they are "dirtier", that is, with more stuff installed.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See bug 4500388, or below.

EXPECTED VERSUS ACTUAL BEHAVIOR :
The system clock gains about 1 second per minute that the
test program runs.

REPRODUCIBILITY :
This bug can be reproduced often.

---------- BEGIN SOURCE ----------
public class ThreadTest {

    public int launchThread(final int id, final int sleepTime) {

        // Create a new thread object
        Thread t = new Thread(new Runnable() {
            public void run() {
                // Loop forever
                while(true) {
                    // Print the ID
                    System.out.print("" + id);
                    // Do some processing
                    for(int i = 0; i < 1000; i++) {
                        for(int j = 0; j < 1000; j++) {
                            double x = (double)i * j / j + i - j * j;
                        }
                    }
// Sleep for the amount specified in the sleep time

                    try {
                        Thread.currentThread().sleep(sleepTime);
                    }
                    catch(InterruptedException e) {
                        ;
                    }
                }
            }
        });
        // Start the thread
        t.start();
        return 0;
    }

    public static void main(String[] args) {
        // Create a Thread that will print the ms time every 30 seconds
        Thread timer = new Thread(new Runnable() {
            public void run() {
                // Print the begin time
                long start = System.currentTimeMillis();
                System.out.println("Start time: " + start);
                try {
                    // Sleep for 10 minutes
                    Thread.currentThread().sleep(300000);
                }
                catch(InterruptedException e) {
                    ;
                }
                // Print the current time
                System.out.println("time: " + (System.currentTimeMillis() -
                  start));
                System.exit(0);
            }
        });
        // Start the timer thread
        // Remove this line of code when it is not desired to stop the app after
10 minutes.
        timer.start();
        // Create a new test base object
        ThreadTest tb = new ThreadTest();

        // Launch a thread with a 5 ms sleep time
        tb.launchThread(1, 5);

        // Launch a thread with a 10 ms sleep time
        tb.launchThread(2, 10);
    }
}
---------- END SOURCE ----------

CUSTOMER WORKAROUND :
Do not use small sleep times.
(Review ID: 165256) 
======================================================================

Comments
EVALUATION This bug was fixed for 4500388. What we may not have made clear to our customers is that the fix requires using a new flag: -XX:+ForceTimeHighResolution This flag and fix are available in 1.3.1_4, 1.4.0_2, 1.4.1 (version?) and 1.4.2. Please let us know if the problem still occurs when running with this flag.
11-06-2004