1 // Test that Thread.sleep() is accurate
2 // and that nanoTime actually measures in nanoseconds.
4 public class Thread_Sleep_2
6 public static void main(String args
[])
11 for (int i
= 0; i
< 100; i
++)
13 long start
= System
.nanoTime();
15 long end
= System
.nanoTime();
16 if ((end
- start
) < 10000000)
18 System
.out
.print ("failed, iteration ");
20 System
.out
.print (", time ");
21 System
.out
.print (end
- start
);
22 System
.out
.println ("ns");
27 System
.out
.println ("ok");
29 catch (InterruptedException x
)
31 System
.out
.println("error: Thread interrupted.");