Accurate Sleep for Java on Windows -
Is there a library that provides thread soth () for Java, which has more error than 1-2 milliseconds is not ?
I tried to mix sleep, error measurement and busy VAT but I do not find it reliable on various Windows machines.
EDIT link provided Nick () is actually a good resource, it could be a native implementation if The implementation is also available for Linux and MacOS. To understand the issues, all types of timers / flags / watches have to go.
To improve sleep nuances, try the following from this page.
Threads under Windows. Bugs with sleep ()
If time for your application is important, then to round these bugs For an unusual but practical way, you have to leave a Daemon thread running throughout your application, which only sleeps for a large number of milliseconds (will be Long.MAX_VALUE). In this way, the barrier period will be set to reduce the effect on the system clock once per your application, and also set the nuances of sleep up to 1 mms, wherever the default interrupt period is not 15ms.
This page also mentions that it causes a system-wide change in Windows that can cause the user's clock to run faster due to this reason.
Edit
More information about this is available and connected to the sun.
Comments
Post a Comment