blob: 55032fd0a7edb8e3c7ce008c609565346401a841 [file] [log] [blame]
jeffhao5d1ac922011-09-29 17:41:15 -07001public class Main {
2 static public void main(String[] args) throws Exception {
3 int millis = 1000;
4
Mathieu Chartier031768a2015-08-27 10:25:02 -07005 if (args.length > 1) {
6 millis = Integer.parseInt(args[1]);
jeffhao5d1ac922011-09-29 17:41:15 -07007 }
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}