885 |
|
public void testAwaitUninterruptibly_fair() { testAwaitUninterruptibly(true); } |
886 |
|
public void testAwaitUninterruptibly(boolean fair) { |
887 |
|
final ReentrantLock lock = new ReentrantLock(fair); |
888 |
< |
final Condition c = lock.newCondition(); |
888 |
> |
final Condition condition = lock.newCondition(); |
889 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(2); |
890 |
|
|
891 |
|
Thread t1 = newStartedThread(new CheckedRunnable() { |
894 |
|
lock.lock(); |
895 |
|
pleaseInterrupt.countDown(); |
896 |
|
Thread.currentThread().interrupt(); |
897 |
< |
c.awaitUninterruptibly(); |
897 |
> |
condition.awaitUninterruptibly(); |
898 |
|
assertTrue(Thread.interrupted()); |
899 |
|
lock.unlock(); |
900 |
|
}}); |
904 |
|
// Interrupt during awaitUninterruptibly |
905 |
|
lock.lock(); |
906 |
|
pleaseInterrupt.countDown(); |
907 |
< |
c.awaitUninterruptibly(); |
907 |
> |
condition.awaitUninterruptibly(); |
908 |
|
assertTrue(Thread.interrupted()); |
909 |
|
lock.unlock(); |
910 |
|
}}); |
911 |
|
|
912 |
|
await(pleaseInterrupt); |
913 |
+ |
t2.interrupt(); |
914 |
|
lock.lock(); |
915 |
|
lock.unlock(); |
916 |
< |
t2.interrupt(); |
917 |
< |
|
917 |
< |
assertThreadStaysAlive(t1); |
918 |
< |
assertTrue(t2.isAlive()); |
916 |
> |
assertThreadBlocks(t1, Thread.State.WAITING); |
917 |
> |
assertThreadBlocks(t2, Thread.State.WAITING); |
918 |
|
|
919 |
|
lock.lock(); |
920 |
< |
c.signalAll(); |
920 |
> |
condition.signalAll(); |
921 |
|
lock.unlock(); |
922 |
|
|
923 |
|
awaitTermination(t1); |