Languages
[Edit]
EN

Java - System.nanoTime() - what this methods really returns

11 points
Created by:
AnnLen
9180

System.nanoTime() method returns the current value of the running Java Virtual Machine's high-resolution time source, in nanoseconds. The best application of this time could be measuring how much time took some operations.

System.nanoTime method usage example

long t1 = System.nanoTime();

Thread.sleep(1000);

long t2 = System.nanoTime();
long dt = t2 - t1;

System.out.println("Sleeping time is " + dt + " ns.");

Output:

Sleeping time is 1000143702 ns.

References

  1. System.nanoTime Method - Oracle Docs
Native Advertising
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join