Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Is the time returned via the real-time clock of better resolution than that returned by System.nanoTime()?

0
Posted

Is the time returned via the real-time clock of better resolution than that returned by System.nanoTime()?

0

The real-time clock and System.nanoTime() are both based on the same system call and thus the same clock. With Java RTS, all time-based APIs (for example, Timers, Periodic Threads, Deadline Monitoring, and so forth) are based on the high-resolution timer. And, together with real-time priorities, they can ensure that the appropriate code will be executed at the right time for real-time constraints. In contrast, ordinary Java SE APIs offer just a few methods capable of handling high-resolution times, with no guarantee of execution at a given time. Using System.nanoTime() between various points in the code to perform elapsed time measurements should always be accurate.

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123