Top community members
All Wiki Articles Create Wiki Article

Welcome to Dirask IT community! ❤ 💻
We are community that shares solutions with each other.

If you think you have something to add here.

you are welcome with your fresh ideas - List Articles

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

0 contributions
11 points

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
0 contributions

Checkout latest Findings & News:

Checkout latest questions:

Checkout latest wiki articles:

Hey 👋
Would you like to know what we do?
  • Dirask is IT community, where we share coding knowledge and help each other to solve coding problems.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.
Read more