2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / testsuite / libjava.lang / Thread_Sleep.java
blobe7f4a81532c0aa46146df7741856638e9c7c7be4
1 // Test that Thread.sleep() works.
2 // Origin: Bryce McKinlay <bryce@albatross.co.nz>
4 public class Thread_Sleep
6 public static void main(String args[])
8 try
10 long start = System.currentTimeMillis();
11 System.out.println("sleeping");
12 Thread.sleep(1000);
13 long end = System.currentTimeMillis();
14 if ((end - start) > 1100 || (end - start) < 990)
15 System.out.println ("failed");
16 else
17 System.out.println("ok");
19 catch (InterruptedException x)
21 System.out.println("error: Thread interrupted.");