source:
trunk/gcc/libjava/testsuite/libjava.lang/Thread_Sleep.java@
3103
| Last change on this file since 3103 was 2, checked in by , 23 years ago | |
|---|---|
|
|
| File size: 576 bytes | |
| Line | |
|---|---|
| 1 | // Test that Thread.sleep() works. |
| 2 | // Origin: Bryce McKinlay <[email protected]> |
| 3 | |
| 4 | public class Thread_Sleep |
| 5 | { |
| 6 | public static void main(String args[]) |
| 7 | { |
| 8 | try |
| 9 | { |
| 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"); |
| 18 | } |
| 19 | catch (InterruptedException x) |
| 20 | { |
| 21 | System.out.println("error: Thread interrupted."); |
| 22 | } |
| 23 | } |
| 24 | } |
Note:
See TracBrowser
for help on using the repository browser.
