1 // Test that Thread.sleep() works. 2 3 public class Thread_Sleep 4 { main(String args[])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 } 24