Original Post
🔒 Locked
Timing In Java?
Advertisement
See here for currentTimeMillis, or if you need higher accuracy, nanoTime (although that can hit your performance depending on how often you use it.) There are also some 3rd party hi-res timers if you need both accuracy and speed, such as the one in LWJGL (I forget its name.)
You don't need to import anything for the 2 above, just use System.currentTimeMillis() or System.nanoTime()
You don't need to import anything for the 2 above, just use System.currentTimeMillis() or System.nanoTime()
You can also use the undocumented and unsupported sun.misc.Perf timer.
But if you just want to delay, something like sleep(10) ought to do it, depending on what exactly you want to accomplish.
private static sun.misc.Perf perf;perf = sun.misc.Perf.getPerf();...freq = perf.highResFrequency(); time = perf.highResCounter() * 1000 / freq;But if you just want to delay, something like sleep(10) ought to do it, depending on what exactly you want to accomplish.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement