|
Last change
on this file since 141 was 2, checked in by bird, 23 years ago |
|
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
|
|
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.