FDO insane profile
[official-gcc.git] / libjava / testsuite / libjava.lang / Thread_Sleep_2.java
blob37c0d3bb6650c58c4dbf092b78ad9352952ec7ce
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[])
8 try
10 boolean ok = true;
11 for (int i = 0; i < 100; i++)
13 long start = System.nanoTime();
14 Thread.sleep(10);
15 long end = System.nanoTime();
16 if ((end - start) < 10000000)
18 System.out.print ("failed, iteration ");
19 System.out.print (i);
20 System.out.print (", time ");
21 System.out.print (end - start);
22 System.out.println ("ns");
23 ok = false;
26 if (ok)
27 System.out.println ("ok");
29 catch (InterruptedException x)
31 System.out.println("error: Thread interrupted.");