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.) |
309 |
|
assertEquals(Long.MIN_VALUE, |
310 |
|
TimeUnit.NANOSECONDS.convert(-Long.MAX_VALUE / 4, |
311 |
|
TimeUnit.DAYS)); |
312 |
– |
|
312 |
|
} |
313 |
|
|
314 |
|
/** |
333 |
|
|
334 |
|
|
335 |
|
/** |
336 |
< |
* Timed wait without holding lock throws |
337 |
< |
* IllegalMonitorStateException |
336 |
> |
* Timed wait without holding lock throws |
337 |
> |
* IllegalMonitorStateException |
338 |
|
*/ |
339 |
|
public void testTimedWait_IllegalMonitorException() throws Exception { |
340 |
|
Thread t = new Thread(new CheckedRunnable() { |
356 |
|
* timedWait throws InterruptedException when interrupted |
357 |
|
*/ |
358 |
|
public void testTimedWait() throws InterruptedException { |
359 |
< |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
360 |
< |
public void realRun() throws InterruptedException { |
359 |
> |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
360 |
> |
public void realRun() throws InterruptedException { |
361 |
|
Object o = new Object(); |
362 |
|
|
363 |
|
TimeUnit tu = TimeUnit.MILLISECONDS; |
364 |
< |
synchronized(o) { |
364 |
> |
synchronized (o) { |
365 |
|
tu.timedWait(o,MEDIUM_DELAY_MS); |
366 |
|
} |
367 |
|
}}); |
368 |
< |
t.start(); |
368 |
> |
t.start(); |
369 |
|
Thread.sleep(SHORT_DELAY_MS); |
370 |
|
t.interrupt(); |
371 |
|
t.join(); |
380 |
|
public void realRun() throws InterruptedException { |
381 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
382 |
|
}}); |
383 |
< |
final Thread t = new Thread(new CheckedInterruptedRunnable() { |
384 |
< |
public void realRun() throws InterruptedException { |
383 |
> |
final Thread t = new Thread(new CheckedInterruptedRunnable() { |
384 |
> |
public void realRun() throws InterruptedException { |
385 |
|
TimeUnit tu = TimeUnit.MILLISECONDS; |
386 |
|
tu.timedJoin(s, MEDIUM_DELAY_MS); |
387 |
|
}});; |
388 |
|
s.start(); |
389 |
< |
t.start(); |
389 |
> |
t.start(); |
390 |
|
Thread.sleep(SHORT_DELAY_MS); |
391 |
|
t.interrupt(); |
392 |
|
t.join(); |
395 |
|
} |
396 |
|
|
397 |
|
/** |
398 |
< |
* timedSleep throws InterruptedException when interrupted |
398 |
> |
* timedSleep throws InterruptedException when interrupted |
399 |
|
*/ |
400 |
|
public void testTimedSleep() throws InterruptedException { |
401 |
< |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
402 |
< |
public void realRun() throws InterruptedException { |
401 |
> |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
402 |
> |
public void realRun() throws InterruptedException { |
403 |
|
TimeUnit tu = TimeUnit.MILLISECONDS; |
404 |
|
tu.sleep(MEDIUM_DELAY_MS); |
405 |
|
}}); |
406 |
|
|
407 |
< |
t.start(); |
407 |
> |
t.start(); |
408 |
|
Thread.sleep(SHORT_DELAY_MS); |
409 |
|
t.interrupt(); |
410 |
|
t.join(); |