Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4814012
Votes 0
Synopsis System clock acceleration on Windows still exists
Category java:runtime
Reported Against 1.4 , 1.3.1 , 1.4.1
Release Fixed
State 11-Closed, duplicate of 4500388, bug
Priority: 4-Low
Related Bugs 6324446 , 4500388
Submit Date 06-FEB-2003
Description




FULL PRODUCT VERSION :
All versions 1.3.1 through 1.4.1

FULL OPERATING SYSTEM VERSION :  customer  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  customer 
        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  customer 
        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) 
======================================================================
Work Around
N/A
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.
Comments
  
  Include a link with my name & email   

Submitted On 16-JUN-2003
triant_rmak
Why not make the fix a default behavior instead of 
requirement the -XX:+ForceTimeHighResolution flag? Or is 
there a downside to that?


Submitted On 24-JUN-2003
brendon9x
All these special 'make the VM work flags' are very nice, but 
you fail address the fact that we can't use them in Java 
Webstart and as we've (almost regrettably) adopted that as 
our deployment solution, we cannot use them.


Submitted On 23-AUG-2006
I am still getting the clock speeding up on JRE 1.5. Dell XP SP2 running your test as shown above results in increase of 15ms per minute (approx). Only happens when both worker threads are running. AND happens even if worker threads sleep for more than 10ms. Any suggestions would be welcome.


Submitted On 05-JAN-2009
Hrishikesh
Hi i m getting the same issue with my test application.. wat workaround would be the best for this



PLEASE NOTE: JDK6 is formerly known as Project Mustang