Max (Weijun) Wang wrote:
> Recently one of my Kerberos tests always reports "replay detected"
> error. Turns out the time precision on Windows is quite low.
>
> I've written this tiny program. It calls new Date().getTime() as fast as
> possible and try to see if the output is continuous:
>
> class A {
> public static void main(String[] rags) throws Exception {
> int[] x = new int[100];
> long l = new java.util.Date().getTime();
> while (true) {
> long m = new java.util.Date().getTime();
> if (m - l >= 100) break;
> x[(int)(m-l)]++;
> }
> for (int i=0; i<100; i++) {
> System.out.printf("%5d %d\n", i, x[i]);
> }
> }
> }
>
> On Linux and Solaris, there are only 2 to 5 zeros in the output, which
> shows the time is quite continuous on these systems. However, on Windows
> (a x64 system), only 1/16th are non zeros, which shows the maximum
> precision on Windows looks like 16 millisec.
Please, someone tell me Windows isn't still using the old 18.2 Hz
DOS timer for its system clock. Nooooo....
Andrew.