OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [testsuite/] [libjava.lang/] [Thread_Sleep_2.java] - Blame information for rev 781

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 765 jeremybenn
// Test that Thread.sleep() is accurate
2
// and that nanoTime actually measures in nanoseconds.
3
 
4
public class Thread_Sleep_2
5
{
6
  public static void main(String args[])
7
  {
8
    try
9
    {
10
      boolean ok = true;
11
      for (int i = 0; i < 100; i++)
12
        {
13
          long start = System.nanoTime();
14
          Thread.sleep(10);
15
          long end = System.nanoTime();
16
          if ((end - start) < 10000000)
17
            {
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;
24
            }
25
        }
26
      if (ok)
27
        System.out.println ("ok");
28
    }
29
    catch (InterruptedException x)
30
    {
31
      System.out.println("error: Thread interrupted.");
32
    }
33
  }
34
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.