19 |
|
import junit.framework.Test; |
20 |
|
import junit.framework.TestSuite; |
21 |
|
|
22 |
+ |
@SuppressWarnings("WaitNotInLoop") // we implement spurious-wakeup freedom |
23 |
|
public class AbstractQueuedLongSynchronizerTest extends JSR166TestCase { |
24 |
|
public static void main(String[] args) { |
25 |
|
main(suite(), args); |
966 |
|
*/ |
967 |
|
public void testAwaitUninterruptibly() { |
968 |
|
final Mutex sync = new Mutex(); |
969 |
< |
final ConditionObject c = sync.newCondition(); |
969 |
> |
final ConditionObject condition = sync.newCondition(); |
970 |
|
final BooleanLatch pleaseInterrupt = new BooleanLatch(); |
971 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
972 |
|
public void realRun() { |
973 |
|
sync.acquire(); |
974 |
|
assertTrue(pleaseInterrupt.releaseShared(0)); |
975 |
< |
c.awaitUninterruptibly(); |
975 |
> |
condition.awaitUninterruptibly(); |
976 |
|
assertTrue(Thread.interrupted()); |
977 |
< |
assertHasWaitersLocked(sync, c, NO_THREADS); |
977 |
> |
assertHasWaitersLocked(sync, condition, NO_THREADS); |
978 |
|
sync.release(); |
979 |
|
}}); |
980 |
|
|
981 |
|
pleaseInterrupt.acquireShared(0); |
982 |
|
sync.acquire(); |
983 |
< |
assertHasWaitersLocked(sync, c, t); |
983 |
> |
assertHasWaitersLocked(sync, condition, t); |
984 |
|
sync.release(); |
985 |
|
t.interrupt(); |
986 |
< |
assertHasWaitersUnlocked(sync, c, t); |
987 |
< |
assertThreadStaysAlive(t); |
986 |
> |
assertHasWaitersUnlocked(sync, condition, t); |
987 |
> |
assertThreadBlocks(t, Thread.State.WAITING); |
988 |
|
sync.acquire(); |
989 |
< |
assertHasWaitersLocked(sync, c, t); |
989 |
> |
assertHasWaitersLocked(sync, condition, t); |
990 |
|
assertHasExclusiveQueuedThreads(sync, NO_THREADS); |
991 |
< |
c.signal(); |
992 |
< |
assertHasWaitersLocked(sync, c, NO_THREADS); |
991 |
> |
condition.signal(); |
992 |
> |
assertHasWaitersLocked(sync, condition, NO_THREADS); |
993 |
|
assertHasExclusiveQueuedThreads(sync, t); |
994 |
|
sync.release(); |
995 |
|
awaitTermination(t); |
1132 |
|
|
1133 |
|
waitForQueuedThread(l, t); |
1134 |
|
assertFalse(l.isSignalled()); |
1135 |
< |
assertThreadStaysAlive(t); |
1135 |
> |
assertThreadBlocks(t, Thread.State.WAITING); |
1136 |
|
assertHasSharedQueuedThreads(l, t); |
1137 |
|
assertTrue(l.releaseShared(0)); |
1138 |
|
assertTrue(l.isSignalled()); |
1157 |
|
|
1158 |
|
waitForQueuedThread(l, t); |
1159 |
|
assertFalse(l.isSignalled()); |
1160 |
< |
assertThreadStaysAlive(t); |
1160 |
> |
assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
1161 |
|
assertTrue(l.releaseShared(0)); |
1162 |
|
assertTrue(l.isSignalled()); |
1163 |
|
awaitTermination(t); |