965 |
|
*/ |
966 |
|
public void testAwaitUninterruptibly() { |
967 |
|
final Mutex sync = new Mutex(); |
968 |
< |
final ConditionObject c = sync.newCondition(); |
968 |
> |
final ConditionObject condition = sync.newCondition(); |
969 |
|
final BooleanLatch pleaseInterrupt = new BooleanLatch(); |
970 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
971 |
|
public void realRun() { |
972 |
|
sync.acquire(); |
973 |
|
assertTrue(pleaseInterrupt.releaseShared(0)); |
974 |
< |
c.awaitUninterruptibly(); |
974 |
> |
condition.awaitUninterruptibly(); |
975 |
|
assertTrue(Thread.interrupted()); |
976 |
< |
assertHasWaitersLocked(sync, c, NO_THREADS); |
976 |
> |
assertHasWaitersLocked(sync, condition, NO_THREADS); |
977 |
|
sync.release(); |
978 |
|
}}); |
979 |
|
|
980 |
|
pleaseInterrupt.acquireShared(0); |
981 |
|
sync.acquire(); |
982 |
< |
assertHasWaitersLocked(sync, c, t); |
982 |
> |
assertHasWaitersLocked(sync, condition, t); |
983 |
|
sync.release(); |
984 |
|
t.interrupt(); |
985 |
< |
assertHasWaitersUnlocked(sync, c, t); |
986 |
< |
assertThreadStaysAlive(t); |
985 |
> |
assertHasWaitersUnlocked(sync, condition, t); |
986 |
> |
assertThreadBlocks(t, Thread.State.WAITING); |
987 |
|
sync.acquire(); |
988 |
< |
assertHasWaitersLocked(sync, c, t); |
988 |
> |
assertHasWaitersLocked(sync, condition, t); |
989 |
|
assertHasExclusiveQueuedThreads(sync, NO_THREADS); |
990 |
< |
c.signal(); |
991 |
< |
assertHasWaitersLocked(sync, c, NO_THREADS); |
990 |
> |
condition.signal(); |
991 |
> |
assertHasWaitersLocked(sync, condition, NO_THREADS); |
992 |
|
assertHasExclusiveQueuedThreads(sync, t); |
993 |
|
sync.release(); |
994 |
|
awaitTermination(t); |