944 |
|
} |
945 |
|
|
946 |
|
/** |
947 |
< |
* awaitUninterruptibly doesn't abort on interrupt |
947 |
> |
* awaitUninterruptibly is uninterruptible |
948 |
|
*/ |
949 |
|
public void testAwaitUninterruptibly() { |
950 |
|
final Mutex sync = new Mutex(); |
951 |
|
final ConditionObject c = sync.newCondition(); |
952 |
< |
final BooleanLatch acquired = new BooleanLatch(); |
952 |
> |
final BooleanLatch pleaseInterrupt = new BooleanLatch(); |
953 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
954 |
|
public void realRun() { |
955 |
|
sync.acquire(); |
956 |
< |
assertTrue(acquired.releaseShared(0)); |
956 |
> |
assertTrue(pleaseInterrupt.releaseShared(0)); |
957 |
|
c.awaitUninterruptibly(); |
958 |
|
assertTrue(Thread.interrupted()); |
959 |
|
assertHasWaitersLocked(sync, c, NO_THREADS); |
960 |
|
sync.release(); |
961 |
|
}}); |
962 |
|
|
963 |
< |
acquired.acquireShared(0); |
963 |
> |
pleaseInterrupt.acquireShared(0); |
964 |
|
sync.acquire(); |
965 |
|
assertHasWaitersLocked(sync, c, t); |
966 |
|
sync.release(); |
987 |
|
public void testInterruptible(final AwaitMethod awaitMethod) { |
988 |
|
final Mutex sync = new Mutex(); |
989 |
|
final ConditionObject c = sync.newCondition(); |
990 |
< |
final BooleanLatch acquired = new BooleanLatch(); |
990 |
> |
final BooleanLatch pleaseInterrupt = new BooleanLatch(); |
991 |
|
Thread t = newStartedThread(new CheckedInterruptedRunnable() { |
992 |
|
public void realRun() throws InterruptedException { |
993 |
|
sync.acquire(); |
994 |
< |
assertTrue(acquired.releaseShared(0)); |
994 |
> |
assertTrue(pleaseInterrupt.releaseShared(0)); |
995 |
|
await(c, awaitMethod); |
996 |
|
}}); |
997 |
|
|
998 |
< |
acquired.acquireShared(0); |
998 |
> |
pleaseInterrupt.acquireShared(0); |
999 |
|
t.interrupt(); |
1000 |
|
awaitTermination(t); |
1001 |
|
} |