1 public class Main { main(String[] args)2 static public void main(String[] args) throws Exception { 3 int millis = 1000; 4 5 if (args.length > 1) { 6 millis = Integer.parseInt(args[1]); 7 } 8 9 System.out.println("Sleeping " + millis + " msec..."); 10 11 long start = System.currentTimeMillis(); 12 Thread.sleep(millis); 13 long elapsed = System.currentTimeMillis() - start; 14 long offBy = Math.abs(elapsed - millis); 15 16 System.out.println("Done sleeping"); 17 18 if (offBy > 250) { 19 System.out.println("Actually slept about " + elapsed + " msec..."); 20 } 21 } 22 } 23