src/java.base/share/classes/java/lang/System.java

Print this page
rev 11263 : 8069269: (spec) Defect in the System.nanoTime spec
Summary: Change description of suggested way to compare two nanoTime values.
Reviewed-by: TBD

@@ -375,22 +375,24 @@
      * <p>The values returned by this method become meaningful only when
      * the difference between two such values, obtained within the same
      * instance of a Java virtual machine, is computed.
      *
      * <p> For example, to measure how long some code takes to execute:
-     *  <pre> {@code
+     * <pre>{@code
      * long startTime = System.nanoTime();
      * // ... the code being measured ...
-     * long estimatedTime = System.nanoTime() - startTime;}</pre>
+     * long estimatedTime = System.nanoTime() - startTime;
+     * }</pre>
      *
      * <p>To compare two nanoTime values
-     *  <pre> {@code
+     * <pre>{@code
      * long t0 = System.nanoTime();
      * ...
-     * long t1 = System.nanoTime();}</pre>
+     * long t1 = System.nanoTime();
+     * }</pre>
      *
-     * one should use {@code t1 - t0 < 0}, not {@code t1 < t0},
+     * one should use {@code t0 - t1 < 0}, not {@code t0 < t1},
      * because of the possibility of numerical overflow.
      *
      * @return the current value of the running Java Virtual Machine's
      *         high-resolution time source, in nanoseconds
      * @since 1.5