| The Android Open Source Project | 2ad60cf | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1 | public class Main { |
| 2 | static public void main(String[] args) throws Exception { |
| 3 | int millis = 1000; |
| 4 | |
| 5 | if (args.length != 0) { |
| 6 | millis = Integer.parseInt(args[0]); |
| 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 | } |