> I am trying to get system time in accurate milliseconds units (for example
> 582ms).
> I use the method System.currentTimeMillis() in jdk 1.2.2, on Windows 98
> platform. I manage to get accuracy of up to 10 milliseconds units only (for
> example either 580 ms 0r 590 ms). How can I get higher resolution?
Change your OS. AFAIU, Java's ability to
cut time into small slices is entirely
dependent on the clock of the underlying OS.
For older Windows, for example, I seem to
recall a time granularity of 55 msec..

Signature
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Erwin Moller - 07 Sep 2004 15:29 GMT
>> I am trying to get system time in accurate milliseconds units (for
>> example 582ms).
[quoted text clipped - 8 lines]
> For older Windows, for example, I seem to
> recall a time granularity of 55 msec..
Hi Andrew,
Just out of curiosity:
Did you find this 55 msec granularity also on comps with a different
CPU-speed or architecture?
Another way to put it: Do you think it depends on the OS or the
architecture/CPU-speed ? Or maybe both?
Regards,
Erwin Moller
Andrew Thompson - 07 Sep 2004 15:55 GMT
> Another way to put it: Do you think it depends on the OS or the
> architecture/CPU-speed ? Or maybe both?
..errr. I'm getting onto ever thinner ground here.
I have not dealt with the time/granularity issue
directly. OTOH, I do recall hearing that when Win
was stuck at 55 msec granularity, the Linux
folks were boasting (and yes I think it was..)
10 msec on the Linux OS.
That *suggests* to me, that the '10 msec' is set
by the underlying hardware, while the '55 msec'
was a quirk of the OS.. Though now I think about
it, I cannot figure why the longer delay is not
an integral number of the 10 msec (50msec/60msec).
Anyone?

Signature
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Matt Humphrey - 07 Sep 2004 16:33 GMT
> > Another way to put it: Do you think it depends on the OS or the
> > architecture/CPU-speed ? Or maybe both?
[quoted text clipped - 11 lines]
> it, I cannot figure why the longer delay is not
> an integral number of the 10 msec (50msec/60msec).
According to Roedy...
http://mindprod.com/jgloss/time.html
Boudewijn Dijkstra - 08 Sep 2004 22:12 GMT
> > I am trying to get system time in accurate milliseconds units (for example
> > 582ms).
[quoted text clipped - 5 lines]
> cut time into small slices is entirely
> dependent on the clock of the underlying OS.
Yes. But in Windows, Java calls GetSystemTime function to get the time,
instead of the high-resolution counter function QueryPerformanceCounter, which
has been there since Win95 and WNT3.1.
> For older Windows, for example, I seem to
> recall a time granularity of 55 msec..
This was due to an MS-DOS clock that was limited to 18.2 Hz IIRC.
> Hi!
>
> I am trying to get system time in accurate milliseconds units (for example
> 582ms).
You can't do this without replacing your computer and your operating system.
In the bad old days of personal computers, the time slice was 1/18.2
second, or 54.9 milliseconds. Things may have improved somewhat since then,
but this time slice doesn't decrease in size as the computer's processor
clock increases in speed -- it is related to the real-time clock more than
to the CPU clock. And I don't think there is any great pressure to decrease
the time slice value on typical systems.
> I use the method System.currentTimeMillis() in jdk 1.2.2, on Windows 98
> platform. I manage to get accuracy of up to 10 milliseconds units only
> (for example either 580 ms 0r 590 ms). How can I get higher resolution?
See above. Why not state the problem to be solved? It's important to realize
we are not discussing real-time operating systems, and a long interrupt by
a process with higher priority than yours will most certainly ruin all your
plans anyway.

Signature
Paul Lutus
http://www.arachnoid.com
Amit - 08 Sep 2004 12:08 GMT
Thank you Andrew, Erwin, Matt and Paul! You have been of great help.
I will try the solution offered by Matt. See if it does any good.
Again, thanks a lot - I did not expect such a warm wecome to the group!
Amit
>> Hi!
>>
[quoted text clipped - 23 lines]
> your
> plans anyway.
Princess Morgiah - 09 Sep 2004 22:10 GMT
> Thank you Andrew, Erwin, Matt and Paul! You have been of great help.
>
> I will try the solution offered by Matt. See if it does any good.
>
> Again, thanks a lot - I did not expect such a warm wecome to the group!
And another warm welcome to the group!
I see you already have a solution, but I'd like to point you to the
following thread:
http://groups.google.com/groups?q=timer+group:*.java+author:princess+author:
morgiah&hl=nl&lr=&ie=UTF-8&selm=YAK3c.30096%24f01.2220062%40phobos.telenet-o
ps.be&rnum=1
At this moment I haven't got much time (working double shifts here), but
should you be interested feel free to mail me or reply to get the source
code for the timer.
Regards,
Princess Morgiah