13 |
|
|
14 |
|
public class TimeUnitTest extends JSR166TestCase { |
15 |
|
public static void main(String[] args) { |
16 |
< |
junit.textui.TestRunner.run(suite()); |
16 |
> |
junit.textui.TestRunner.run(suite()); |
17 |
|
} |
18 |
|
|
19 |
|
public static Test suite() { |
20 |
< |
return new TestSuite(TimeUnitTest.class); |
20 |
> |
return new TestSuite(TimeUnitTest.class); |
21 |
|
} |
22 |
|
|
23 |
|
// (loops to 88888 check increments at all time divisions.) |
357 |
|
* timedWait throws InterruptedException when interrupted |
358 |
|
*/ |
359 |
|
public void testTimedWait() throws InterruptedException { |
360 |
< |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
361 |
< |
public void realRun() throws InterruptedException { |
360 |
> |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
361 |
> |
public void realRun() throws InterruptedException { |
362 |
|
Object o = new Object(); |
363 |
|
|
364 |
|
TimeUnit tu = TimeUnit.MILLISECONDS; |
366 |
|
tu.timedWait(o,MEDIUM_DELAY_MS); |
367 |
|
} |
368 |
|
}}); |
369 |
< |
t.start(); |
369 |
> |
t.start(); |
370 |
|
Thread.sleep(SHORT_DELAY_MS); |
371 |
|
t.interrupt(); |
372 |
|
t.join(); |
381 |
|
public void realRun() throws InterruptedException { |
382 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
383 |
|
}}); |
384 |
< |
final Thread t = new Thread(new CheckedInterruptedRunnable() { |
385 |
< |
public void realRun() throws InterruptedException { |
384 |
> |
final Thread t = new Thread(new CheckedInterruptedRunnable() { |
385 |
> |
public void realRun() throws InterruptedException { |
386 |
|
TimeUnit tu = TimeUnit.MILLISECONDS; |
387 |
|
tu.timedJoin(s, MEDIUM_DELAY_MS); |
388 |
|
}});; |
389 |
|
s.start(); |
390 |
< |
t.start(); |
390 |
> |
t.start(); |
391 |
|
Thread.sleep(SHORT_DELAY_MS); |
392 |
|
t.interrupt(); |
393 |
|
t.join(); |
399 |
|
* timedSleep throws InterruptedException when interrupted |
400 |
|
*/ |
401 |
|
public void testTimedSleep() throws InterruptedException { |
402 |
< |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
403 |
< |
public void realRun() throws InterruptedException { |
402 |
> |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
403 |
> |
public void realRun() throws InterruptedException { |
404 |
|
TimeUnit tu = TimeUnit.MILLISECONDS; |
405 |
|
tu.sleep(MEDIUM_DELAY_MS); |
406 |
|
}}); |
407 |
|
|
408 |
< |
t.start(); |
408 |
> |
t.start(); |
409 |
|
Thread.sleep(SHORT_DELAY_MS); |
410 |
|
t.interrupt(); |
411 |
|
t.join(); |