2000-03-23 20:35:44 +08:00
|
|
|
// Test that Thread.sleep() works.
|
|
|
|
|
|
|
|
public class Thread_Sleep
|
|
|
|
{
|
|
|
|
public static void main(String args[])
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
System.out.println("sleeping");
|
2004-07-28 10:44:06 +08:00
|
|
|
Thread.sleep(50);
|
2000-03-23 20:35:44 +08:00
|
|
|
long end = System.currentTimeMillis();
|
2004-07-28 10:44:06 +08:00
|
|
|
if ((end - start) < 50)
|
2000-03-23 20:35:44 +08:00
|
|
|
System.out.println ("failed");
|
|
|
|
else
|
|
|
|
System.out.println("ok");
|
|
|
|
}
|
|
|
|
catch (InterruptedException x)
|
|
|
|
{
|
|
|
|
System.out.println("error: Thread interrupted.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|