OSDN Git Service

PR java/16789:
[pf3gnuchains/gcc-fork.git] / libjava / testsuite / libjava.lang / Thread_Sleep.java
1 // Test that Thread.sleep() works.
2
3 public class Thread_Sleep
4 {
5   public static void main(String args[])
6   {
7     try
8     {
9       long start = System.currentTimeMillis();
10       System.out.println("sleeping");
11       Thread.sleep(50);
12       long end = System.currentTimeMillis();
13       if ((end - start) < 50)
14         System.out.println ("failed");
15       else
16         System.out.println("ok");
17     }
18     catch (InterruptedException x)
19     {
20       System.out.println("error: Thread interrupted.");
21     }
22   }
23 }