ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/AbstractQueuedSynchronizerTest.java
(Generate patch)

Comparing jsr166/src/test/tck/AbstractQueuedSynchronizerTest.java (file contents):
Revision 1.15 by dl, Sat Jan 10 20:37:20 2004 UTC vs.
Revision 1.32 by jsr166, Mon Nov 30 08:31:09 2009 UTC

# Line 2 | Line 2
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4   * http://creativecommons.org/licenses/publicdomain
5 < * Other contributors include Andrew Wright, Jeffrey Hayes,
6 < * Pat Fisher, Mike Judd.
5 > * Other contributors include Andrew Wright, Jeffrey Hayes,
6 > * Pat Fisher, Mike Judd.
7   */
8  
9  
10   import junit.framework.*;
11   import java.util.*;
12   import java.util.concurrent.*;
13 + import static java.util.concurrent.TimeUnit.MILLISECONDS;
14   import java.util.concurrent.locks.*;
15   import java.io.*;
16  
# Line 30 | Line 31 | public class AbstractQueuedSynchronizerT
31       * ReentrantReadWriteLock, and Semaphore
32       */
33      static class Mutex extends AbstractQueuedSynchronizer {
34 <        public boolean isLocked() { return getState() == 1; }
35 <        
36 <        public boolean tryAcquireExclusive(int acquires) {
37 <            assertTrue(acquires == 1);
34 >        public boolean isHeldExclusively() { return getState() == 1; }
35 >
36 >        public boolean tryAcquire(int acquires) {
37 >            assertTrue(acquires == 1);
38              return compareAndSetState(0, 1);
39          }
40 <        
41 <        public boolean tryReleaseExclusive(int releases) {
40 >
41 >        public boolean tryRelease(int releases) {
42 >            if (getState() == 0) throw new IllegalMonitorStateException();
43              setState(0);
44              return true;
45          }
46 <        
45 <        public void checkConditionAccess(Thread thread) {
46 <            if (getState() == 0) throw new IllegalMonitorStateException();
47 <        }
48 <        
46 >
47          public AbstractQueuedSynchronizer.ConditionObject newCondition() { return new AbstractQueuedSynchronizer.ConditionObject(); }
50        
51        public void lock() {
52            acquireExclusiveUninterruptibly(1);
53        }
48  
49      }
50  
51 <    
51 >
52      /**
53       * A simple latch class, to test shared mode.
54       */
55 <    static class BooleanLatch extends AbstractQueuedSynchronizer {
55 >    static class BooleanLatch extends AbstractQueuedSynchronizer {
56          public boolean isSignalled() { return getState() != 0; }
57  
58          public int tryAcquireShared(int ignore) {
59              return isSignalled()? 1 : -1;
60          }
61 <        
61 >
62          public boolean tryReleaseShared(int ignore) {
63              setState(1);
64              return true;
# Line 72 | Line 66 | public class AbstractQueuedSynchronizerT
66      }
67  
68      /**
69 <     * A runnable calling acquireExclusiveInterruptibly
69 >     * A runnable calling acquireInterruptibly that does not expect to
70 >     * be interrupted.
71       */
72 <    class InterruptibleLockRunnable implements Runnable {
73 <        final Mutex lock;
74 <        InterruptibleLockRunnable(Mutex l) { lock = l; }
75 <        public void run() {
76 <            try {
82 <                lock.acquireExclusiveInterruptibly(1);
83 <            } catch(InterruptedException success){}
72 >    class InterruptibleSyncRunnable extends CheckedRunnable {
73 >        final Mutex sync;
74 >        InterruptibleSyncRunnable(Mutex l) { sync = l; }
75 >        public void realRun() throws InterruptedException {
76 >            sync.acquireInterruptibly(1);
77          }
78      }
79  
80  
81      /**
82 <     * A runnable calling acquireExclusiveInterruptibly that expects to be
83 <     * interrupted
82 >     * A runnable calling acquireInterruptibly that expects to be
83 >     * interrupted.
84       */
85 <    class InterruptedLockRunnable implements Runnable {
86 <        final Mutex lock;
87 <        InterruptedLockRunnable(Mutex l) { lock = l; }
88 <        public void run() {
89 <            try {
97 <                lock.acquireExclusiveInterruptibly(1);
98 <                threadShouldThrow();
99 <            } catch(InterruptedException success){}
85 >    class InterruptedSyncRunnable extends CheckedInterruptedRunnable {
86 >        final Mutex sync;
87 >        InterruptedSyncRunnable(Mutex l) { sync = l; }
88 >        public void realRun() throws InterruptedException {
89 >            sync.acquireInterruptibly(1);
90          }
91      }
92 <    
92 >
93 >    /**
94 >     * isHeldExclusively is false upon construction
95 >     */
96 >    public void testIsHeldExclusively() {
97 >        Mutex rl = new Mutex();
98 >        assertFalse(rl.isHeldExclusively());
99 >    }
100 >
101      /**
102 <     * acquireExclusiveUninterruptiblying an releaseExclusiveed lock succeeds
102 >     * acquiring released sync succeeds
103       */
104 <    public void testAcquireExclusiveUninterruptibly() {
105 <        Mutex rl = new Mutex();
106 <        rl.acquireExclusiveUninterruptibly(1);
107 <        assertTrue(rl.isLocked());
108 <        rl.releaseExclusive(1);
104 >    public void testAcquire() {
105 >        Mutex rl = new Mutex();
106 >        rl.acquire(1);
107 >        assertTrue(rl.isHeldExclusively());
108 >        rl.release(1);
109 >        assertFalse(rl.isHeldExclusively());
110      }
111  
112      /**
113 <     * tryAcquireExclusive on an releaseExclusiveed lock succeeds
113 >     * tryAcquire on an released sync succeeds
114       */
115 <    public void testTryAcquireExclusive() {
116 <        Mutex rl = new Mutex();
117 <        assertTrue(rl.tryAcquireExclusive(1));
118 <        assertTrue(rl.isLocked());
119 <        rl.releaseExclusive(1);
115 >    public void testTryAcquire() {
116 >        Mutex rl = new Mutex();
117 >        assertTrue(rl.tryAcquire(1));
118 >        assertTrue(rl.isHeldExclusively());
119 >        rl.release(1);
120      }
121  
122      /**
123       * hasQueuedThreads reports whether there are waiting threads
124       */
125 <    public void testhasQueuedThreads() {
126 <        final Mutex lock = new Mutex();
127 <        Thread t1 = new Thread(new InterruptedLockRunnable(lock));
128 <        Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
129 <        try {
130 <            assertFalse(lock.hasQueuedThreads());
131 <            lock.acquireExclusiveUninterruptibly(1);
132 <            t1.start();
133 <            Thread.sleep(SHORT_DELAY_MS);
134 <            assertTrue(lock.hasQueuedThreads());
135 <            t2.start();
136 <            Thread.sleep(SHORT_DELAY_MS);
137 <            assertTrue(lock.hasQueuedThreads());
138 <            t1.interrupt();
139 <            Thread.sleep(SHORT_DELAY_MS);
140 <            assertTrue(lock.hasQueuedThreads());
141 <            lock.releaseExclusive(1);
142 <            Thread.sleep(SHORT_DELAY_MS);
143 <            assertFalse(lock.hasQueuedThreads());
144 <            t1.join();
145 <            t2.join();
147 <        } catch(Exception e){
148 <            unexpectedException();
149 <        }
150 <    }
125 >    public void testhasQueuedThreads() throws InterruptedException {
126 >        final Mutex sync = new Mutex();
127 >        Thread t1 = new Thread(new InterruptedSyncRunnable(sync));
128 >        Thread t2 = new Thread(new InterruptibleSyncRunnable(sync));
129 >        assertFalse(sync.hasQueuedThreads());
130 >        sync.acquire(1);
131 >        t1.start();
132 >        Thread.sleep(SHORT_DELAY_MS);
133 >        assertTrue(sync.hasQueuedThreads());
134 >        t2.start();
135 >        Thread.sleep(SHORT_DELAY_MS);
136 >        assertTrue(sync.hasQueuedThreads());
137 >        t1.interrupt();
138 >        Thread.sleep(SHORT_DELAY_MS);
139 >        assertTrue(sync.hasQueuedThreads());
140 >        sync.release(1);
141 >        Thread.sleep(SHORT_DELAY_MS);
142 >        assertFalse(sync.hasQueuedThreads());
143 >        t1.join();
144 >        t2.join();
145 >    }
146  
147      /**
148       * isQueued(null) throws NPE
149       */
150 <    public void testIsQueuedNPE() {
151 <        final Mutex lock = new Mutex();
150 >    public void testIsQueuedNPE() {
151 >        final Mutex sync = new Mutex();
152          try {
153 <            lock.isQueued(null);
153 >            sync.isQueued(null);
154              shouldThrow();
155 <        } catch (NullPointerException success) {
161 <        }
155 >        } catch (NullPointerException success) {}
156      }
157  
158      /**
159       * isQueued reports whether a thread is queued.
160       */
161 <    public void testIsQueued() {
162 <        final Mutex lock = new Mutex();
163 <        Thread t1 = new Thread(new InterruptedLockRunnable(lock));
164 <        Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
165 <        try {
166 <            assertFalse(lock.isQueued(t1));
167 <            assertFalse(lock.isQueued(t2));
168 <            lock.acquireExclusiveUninterruptibly(1);
169 <            t1.start();
170 <            Thread.sleep(SHORT_DELAY_MS);
171 <            assertTrue(lock.isQueued(t1));
172 <            t2.start();
173 <            Thread.sleep(SHORT_DELAY_MS);
174 <            assertTrue(lock.isQueued(t1));
175 <            assertTrue(lock.isQueued(t2));
176 <            t1.interrupt();
177 <            Thread.sleep(SHORT_DELAY_MS);
178 <            assertFalse(lock.isQueued(t1));
179 <            assertTrue(lock.isQueued(t2));
180 <            lock.releaseExclusive(1);
181 <            Thread.sleep(SHORT_DELAY_MS);
182 <            assertFalse(lock.isQueued(t1));
183 <            assertFalse(lock.isQueued(t2));
184 <            t1.join();
185 <            t2.join();
186 <        } catch(Exception e){
193 <            unexpectedException();
194 <        }
195 <    }
161 >    public void testIsQueued() throws InterruptedException {
162 >        final Mutex sync = new Mutex();
163 >        Thread t1 = new Thread(new InterruptedSyncRunnable(sync));
164 >        Thread t2 = new Thread(new InterruptibleSyncRunnable(sync));
165 >        assertFalse(sync.isQueued(t1));
166 >        assertFalse(sync.isQueued(t2));
167 >        sync.acquire(1);
168 >        t1.start();
169 >        Thread.sleep(SHORT_DELAY_MS);
170 >        assertTrue(sync.isQueued(t1));
171 >        t2.start();
172 >        Thread.sleep(SHORT_DELAY_MS);
173 >        assertTrue(sync.isQueued(t1));
174 >        assertTrue(sync.isQueued(t2));
175 >        t1.interrupt();
176 >        Thread.sleep(SHORT_DELAY_MS);
177 >        assertFalse(sync.isQueued(t1));
178 >        assertTrue(sync.isQueued(t2));
179 >        sync.release(1);
180 >        Thread.sleep(SHORT_DELAY_MS);
181 >        assertFalse(sync.isQueued(t1));
182 >        Thread.sleep(SHORT_DELAY_MS);
183 >        assertFalse(sync.isQueued(t2));
184 >        t1.join();
185 >        t2.join();
186 >    }
187  
188      /**
189 <     * getFirstQueuedThread returns first waiting thread or null is none
190 <     */
191 <    public void testGetFirstQueuedThread() {
192 <        final Mutex lock = new Mutex();
193 <        Thread t1 = new Thread(new InterruptedLockRunnable(lock));
194 <        Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
195 <        try {
196 <            assertNull(lock.getFirstQueuedThread());
197 <            lock.acquireExclusiveUninterruptibly(1);
198 <            t1.start();
199 <            Thread.sleep(SHORT_DELAY_MS);
200 <            assertEquals(t1, lock.getFirstQueuedThread());
201 <            t2.start();
202 <            Thread.sleep(SHORT_DELAY_MS);
203 <            assertEquals(t1, lock.getFirstQueuedThread());
204 <            t1.interrupt();
205 <            Thread.sleep(SHORT_DELAY_MS);
206 <            assertEquals(t2, lock.getFirstQueuedThread());
207 <            lock.releaseExclusive(1);
208 <            Thread.sleep(SHORT_DELAY_MS);
209 <            assertNull(lock.getFirstQueuedThread());
210 <            t1.join();
211 <            t2.join();
212 <        } catch(Exception e){
222 <            unexpectedException();
223 <        }
224 <    }
189 >     * getFirstQueuedThread returns first waiting thread or null if none
190 >     */
191 >    public void testGetFirstQueuedThread() throws InterruptedException {
192 >        final Mutex sync = new Mutex();
193 >        Thread t1 = new Thread(new InterruptedSyncRunnable(sync));
194 >        Thread t2 = new Thread(new InterruptibleSyncRunnable(sync));
195 >        assertNull(sync.getFirstQueuedThread());
196 >        sync.acquire(1);
197 >        t1.start();
198 >        Thread.sleep(SHORT_DELAY_MS);
199 >        assertEquals(t1, sync.getFirstQueuedThread());
200 >        t2.start();
201 >        Thread.sleep(SHORT_DELAY_MS);
202 >        assertEquals(t1, sync.getFirstQueuedThread());
203 >        t1.interrupt();
204 >        Thread.sleep(SHORT_DELAY_MS);
205 >        Thread.sleep(SHORT_DELAY_MS);
206 >        assertEquals(t2, sync.getFirstQueuedThread());
207 >        sync.release(1);
208 >        Thread.sleep(SHORT_DELAY_MS);
209 >        assertNull(sync.getFirstQueuedThread());
210 >        t1.join();
211 >        t2.join();
212 >    }
213  
214  
215      /**
216       * hasContended reports false if no thread has ever blocked, else true
217       */
218 <    public void testHasContended() {
219 <        final Mutex lock = new Mutex();
220 <        Thread t1 = new Thread(new InterruptedLockRunnable(lock));
221 <        Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
222 <        try {
223 <            assertFalse(lock.hasContended());
224 <            lock.acquireExclusiveUninterruptibly(1);
225 <            t1.start();
226 <            Thread.sleep(SHORT_DELAY_MS);
227 <            assertTrue(lock.hasContended());
228 <            t2.start();
229 <            Thread.sleep(SHORT_DELAY_MS);
230 <            assertTrue(lock.hasContended());
231 <            t1.interrupt();
232 <            Thread.sleep(SHORT_DELAY_MS);
233 <            assertTrue(lock.hasContended());
234 <            lock.releaseExclusive(1);
235 <            Thread.sleep(SHORT_DELAY_MS);
236 <            assertTrue(lock.hasContended());
237 <            t1.join();
238 <            t2.join();
239 <        } catch(Exception e){
240 <            unexpectedException();
241 <        }
242 <    }
218 >    public void testHasContended() throws InterruptedException {
219 >        final Mutex sync = new Mutex();
220 >        Thread t1 = new Thread(new InterruptedSyncRunnable(sync));
221 >        Thread t2 = new Thread(new InterruptibleSyncRunnable(sync));
222 >        assertFalse(sync.hasContended());
223 >        sync.acquire(1);
224 >        t1.start();
225 >        Thread.sleep(SHORT_DELAY_MS);
226 >        assertTrue(sync.hasContended());
227 >        t2.start();
228 >        Thread.sleep(SHORT_DELAY_MS);
229 >        assertTrue(sync.hasContended());
230 >        t1.interrupt();
231 >        Thread.sleep(SHORT_DELAY_MS);
232 >        assertTrue(sync.hasContended());
233 >        sync.release(1);
234 >        Thread.sleep(SHORT_DELAY_MS);
235 >        assertTrue(sync.hasContended());
236 >        t1.join();
237 >        t2.join();
238 >    }
239 >
240 >    /**
241 >     * getQueuedThreads includes waiting threads
242 >     */
243 >    public void testGetQueuedThreads() throws InterruptedException {
244 >        final Mutex sync = new Mutex();
245 >        Thread t1 = new Thread(new InterruptedSyncRunnable(sync));
246 >        Thread t2 = new Thread(new InterruptibleSyncRunnable(sync));
247 >        assertTrue(sync.getQueuedThreads().isEmpty());
248 >        sync.acquire(1);
249 >        assertTrue(sync.getQueuedThreads().isEmpty());
250 >        t1.start();
251 >        Thread.sleep(SHORT_DELAY_MS);
252 >        assertTrue(sync.getQueuedThreads().contains(t1));
253 >        t2.start();
254 >        Thread.sleep(SHORT_DELAY_MS);
255 >        assertTrue(sync.getQueuedThreads().contains(t1));
256 >        assertTrue(sync.getQueuedThreads().contains(t2));
257 >        t1.interrupt();
258 >        Thread.sleep(SHORT_DELAY_MS);
259 >        assertFalse(sync.getQueuedThreads().contains(t1));
260 >        assertTrue(sync.getQueuedThreads().contains(t2));
261 >        sync.release(1);
262 >        Thread.sleep(SHORT_DELAY_MS);
263 >        assertTrue(sync.getQueuedThreads().isEmpty());
264 >        t1.join();
265 >        t2.join();
266 >    }
267 >
268 >    /**
269 >     * getExclusiveQueuedThreads includes waiting threads
270 >     */
271 >    public void testGetExclusiveQueuedThreads() throws InterruptedException {
272 >        final Mutex sync = new Mutex();
273 >        Thread t1 = new Thread(new InterruptedSyncRunnable(sync));
274 >        Thread t2 = new Thread(new InterruptibleSyncRunnable(sync));
275 >        assertTrue(sync.getExclusiveQueuedThreads().isEmpty());
276 >        sync.acquire(1);
277 >        assertTrue(sync.getExclusiveQueuedThreads().isEmpty());
278 >        t1.start();
279 >        Thread.sleep(SHORT_DELAY_MS);
280 >        assertTrue(sync.getExclusiveQueuedThreads().contains(t1));
281 >        t2.start();
282 >        Thread.sleep(SHORT_DELAY_MS);
283 >        assertTrue(sync.getExclusiveQueuedThreads().contains(t1));
284 >        assertTrue(sync.getExclusiveQueuedThreads().contains(t2));
285 >        t1.interrupt();
286 >        Thread.sleep(SHORT_DELAY_MS);
287 >        assertFalse(sync.getExclusiveQueuedThreads().contains(t1));
288 >        assertTrue(sync.getExclusiveQueuedThreads().contains(t2));
289 >        sync.release(1);
290 >        Thread.sleep(SHORT_DELAY_MS);
291 >        assertTrue(sync.getExclusiveQueuedThreads().isEmpty());
292 >        t1.join();
293 >        t2.join();
294 >    }
295 >
296 >    /**
297 >     * getSharedQueuedThreads does not include exclusively waiting threads
298 >     */
299 >    public void testGetSharedQueuedThreads() throws InterruptedException {
300 >        final Mutex sync = new Mutex();
301 >        Thread t1 = new Thread(new InterruptedSyncRunnable(sync));
302 >        Thread t2 = new Thread(new InterruptibleSyncRunnable(sync));
303 >        assertTrue(sync.getSharedQueuedThreads().isEmpty());
304 >        sync.acquire(1);
305 >        assertTrue(sync.getSharedQueuedThreads().isEmpty());
306 >        t1.start();
307 >        Thread.sleep(SHORT_DELAY_MS);
308 >        assertTrue(sync.getSharedQueuedThreads().isEmpty());
309 >        t2.start();
310 >        Thread.sleep(SHORT_DELAY_MS);
311 >        assertTrue(sync.getSharedQueuedThreads().isEmpty());
312 >        t1.interrupt();
313 >        Thread.sleep(SHORT_DELAY_MS);
314 >        assertTrue(sync.getSharedQueuedThreads().isEmpty());
315 >        sync.release(1);
316 >        Thread.sleep(SHORT_DELAY_MS);
317 >        assertTrue(sync.getSharedQueuedThreads().isEmpty());
318 >        t1.join();
319 >        t2.join();
320 >    }
321 >
322 >    /**
323 >     * tryAcquireNanos is interruptible.
324 >     */
325 >    public void testInterruptedException2() throws InterruptedException {
326 >        final Mutex sync = new Mutex();
327 >        sync.acquire(1);
328 >        Thread t = new Thread(new CheckedInterruptedRunnable() {
329 >            public void realRun() throws InterruptedException {
330 >                sync.tryAcquireNanos(1, MEDIUM_DELAY_MS * 1000L * 1000L);
331 >            }});
332  
333 <    /**
334 <     * acquireExclusiveNanos is interruptible.
335 <     */
336 <    public void testInterruptedException2() {
260 <        final Mutex lock = new Mutex();
261 <        lock.acquireExclusiveUninterruptibly(1);
262 <        Thread t = new Thread(new Runnable() {
263 <                public void run() {
264 <                    try {
265 <                        lock.acquireExclusiveNanos(1, MEDIUM_DELAY_MS * 1000 * 1000);
266 <                        threadShouldThrow();
267 <                    } catch(InterruptedException success){}
268 <                }
269 <            });
270 <        try {
271 <            t.start();
272 <            t.interrupt();
273 <        } catch(Exception e){
274 <            unexpectedException();
275 <        }
333 >        t.start();
334 >        Thread.sleep(SHORT_DELAY_MS);
335 >        t.interrupt();
336 >        t.join();
337      }
338  
339  
340      /**
341 <     * TryAcquireExclusive on a locked lock fails
341 >     * TryAcquire on exclusively held sync fails
342       */
343 <    public void testTryAcquireExclusiveWhenLocked() {
344 <        final Mutex lock = new Mutex();
345 <        lock.acquireExclusiveUninterruptibly(1);
346 <        Thread t = new Thread(new Runnable() {
347 <                public void run() {
348 <                    threadAssertFalse(lock.tryAcquireExclusive(1));
349 <                }
350 <            });
351 <        try {
352 <            t.start();
353 <            t.join();
354 <            lock.releaseExclusive(1);
294 <        } catch(Exception e){
295 <            unexpectedException();
296 <        }
297 <    }
343 >    public void testTryAcquireWhenSynced() throws InterruptedException {
344 >        final Mutex sync = new Mutex();
345 >        sync.acquire(1);
346 >        Thread t = new Thread(new CheckedRunnable() {
347 >            public void realRun() {
348 >                threadAssertFalse(sync.tryAcquire(1));
349 >            }});
350 >
351 >        t.start();
352 >        t.join();
353 >        sync.release(1);
354 >    }
355  
356      /**
357 <     * acquireExclusiveNanos on a locked lock times out
357 >     * tryAcquireNanos on an exclusively held sync times out
358       */
359 <    public void testAcquireExclusiveNanos_Timeout() {
360 <        final Mutex lock = new Mutex();
361 <        lock.acquireExclusiveUninterruptibly(1);
362 <        Thread t = new Thread(new Runnable() {
363 <                public void run() {
364 <                    try {
365 <                        threadAssertFalse(lock.acquireExclusiveNanos(1, 1000 * 1000));
366 <                    } catch (Exception ex) {
367 <                        threadUnexpectedException();
368 <                    }
369 <                }
370 <            });
371 <        try {
372 <            t.start();
316 <            t.join();
317 <            lock.releaseExclusive(1);
318 <        } catch(Exception e){
319 <            unexpectedException();
320 <        }
321 <    }
322 <    
323 <  
359 >    public void testAcquireNanos_Timeout() throws InterruptedException {
360 >        final Mutex sync = new Mutex();
361 >        sync.acquire(1);
362 >        Thread t = new Thread(new CheckedRunnable() {
363 >            public void realRun() throws InterruptedException {
364 >                threadAssertFalse(sync.tryAcquireNanos(1, SHORT_DELAY_MS * 1000L * 1000L));
365 >            }});
366 >
367 >        t.start();
368 >        t.join();
369 >        sync.release(1);
370 >    }
371 >
372 >
373      /**
374       * getState is true when acquired and false when not
375       */
376 <    public void testGetState() {
377 <        final Mutex lock = new Mutex();
378 <        lock.acquireExclusiveUninterruptibly(1);
379 <        assertTrue(lock.isLocked());
380 <        lock.releaseExclusive(1);
381 <        assertFalse(lock.isLocked());
382 <        Thread t = new Thread(new Runnable() {
383 <                public void run() {
384 <                    lock.acquireExclusiveUninterruptibly(1);
385 <                    try {
386 <                        Thread.sleep(SMALL_DELAY_MS);
387 <                    }
388 <                    catch(Exception e) {
389 <                        threadUnexpectedException();
390 <                    }
391 <                    lock.releaseExclusive(1);
392 <                }
393 <            });
345 <        try {
346 <            t.start();
347 <            Thread.sleep(SHORT_DELAY_MS);
348 <            assertTrue(lock.isLocked());
349 <            t.join();
350 <            assertFalse(lock.isLocked());
351 <        } catch(Exception e){
352 <            unexpectedException();
353 <        }
376 >    public void testGetState() throws InterruptedException {
377 >        final Mutex sync = new Mutex();
378 >        sync.acquire(1);
379 >        assertTrue(sync.isHeldExclusively());
380 >        sync.release(1);
381 >        assertFalse(sync.isHeldExclusively());
382 >        Thread t = new Thread(new CheckedRunnable() {
383 >            public void realRun() throws InterruptedException {
384 >                sync.acquire(1);
385 >                Thread.sleep(SMALL_DELAY_MS);
386 >                sync.release(1);
387 >            }});
388 >
389 >        t.start();
390 >        Thread.sleep(SHORT_DELAY_MS);
391 >        assertTrue(sync.isHeldExclusively());
392 >        t.join();
393 >        assertFalse(sync.isHeldExclusively());
394      }
395  
396  
397      /**
398 <     * acquireExclusiveInterruptibly is interruptible.
398 >     * acquireInterruptibly is interruptible.
399       */
400 <    public void testAcquireInterruptibly1() {
401 <        final Mutex lock = new Mutex();
402 <        lock.acquireExclusiveUninterruptibly(1);
403 <        Thread t = new Thread(new InterruptedLockRunnable(lock));
404 <        try {
405 <            t.start();
406 <            t.interrupt();
407 <            lock.releaseExclusive(1);
408 <            t.join();
409 <        } catch(Exception e){
410 <            unexpectedException();
411 <        }
372 <    }
400 >    public void testAcquireInterruptibly1() throws InterruptedException {
401 >        final Mutex sync = new Mutex();
402 >        sync.acquire(1);
403 >        Thread t = new Thread(new InterruptedSyncRunnable(sync));
404 >
405 >        t.start();
406 >        Thread.sleep(SHORT_DELAY_MS);
407 >        t.interrupt();
408 >        Thread.sleep(SHORT_DELAY_MS);
409 >        sync.release(1);
410 >        t.join();
411 >    }
412  
413      /**
414 <     * acquireExclusiveInterruptibly succeeds when released, else is interruptible
414 >     * acquireInterruptibly succeeds when released, else is interruptible
415       */
416 <    public void testAcquireInterruptibly2() {
417 <        final Mutex lock = new Mutex();
418 <        try {
419 <            lock.acquireExclusiveInterruptibly(1);
420 <        } catch(Exception e) {
421 <            unexpectedException();
422 <        }
423 <        Thread t = new Thread(new InterruptedLockRunnable(lock));
424 <        try {
386 <            t.start();
387 <            t.interrupt();
388 <            assertTrue(lock.isLocked());
389 <            t.join();
390 <        } catch(Exception e){
391 <            unexpectedException();
392 <        }
416 >    public void testAcquireInterruptibly2() throws InterruptedException {
417 >        final Mutex sync = new Mutex();
418 >        sync.acquireInterruptibly(1);
419 >        Thread t = new Thread(new InterruptedSyncRunnable(sync));
420 >        t.start();
421 >        Thread.sleep(SHORT_DELAY_MS);
422 >        t.interrupt();
423 >        assertTrue(sync.isHeldExclusively());
424 >        t.join();
425      }
426  
427      /**
428 <     * owns is true for a condition created by lock else false
428 >     * owns is true for a condition created by sync else false
429       */
430      public void testOwns() {
431 <        final Mutex lock = new Mutex();
432 <        final AbstractQueuedSynchronizer.ConditionObject c = lock.newCondition();
433 <        final Mutex lock2 = new Mutex();
434 <        assertTrue(lock.owns(c));
435 <        assertFalse(lock2.owns(c));
431 >        final Mutex sync = new Mutex();
432 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
433 >        final Mutex sync2 = new Mutex();
434 >        assertTrue(sync.owns(c));
435 >        assertFalse(sync2.owns(c));
436      }
437  
438      /**
439 <     * Calling await without holding lock throws IllegalMonitorStateException
439 >     * Calling await without holding sync throws IllegalMonitorStateException
440       */
441 <    public void testAwait_IllegalMonitor() {
442 <        final Mutex lock = new Mutex();
443 <        final AbstractQueuedSynchronizer.ConditionObject c = lock.newCondition();
441 >    public void testAwait_IllegalMonitor() throws InterruptedException {
442 >        final Mutex sync = new Mutex();
443 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
444          try {
445              c.await();
446              shouldThrow();
447 <        }
416 <        catch (IllegalMonitorStateException success) {
417 <        }
418 <        catch (Exception ex) {
419 <            unexpectedException();
420 <        }
447 >        } catch (IllegalMonitorStateException success) {}
448      }
449  
450      /**
451 <     * Calling signal without holding lock throws IllegalMonitorStateException
451 >     * Calling signal without holding sync throws IllegalMonitorStateException
452       */
453      public void testSignal_IllegalMonitor() {
454 <        final Mutex lock = new Mutex();
455 <        final AbstractQueuedSynchronizer.ConditionObject c = lock.newCondition();
454 >        final Mutex sync = new Mutex();
455 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
456          try {
457              c.signal();
458              shouldThrow();
459 <        }
433 <        catch (IllegalMonitorStateException success) {
434 <        }
435 <        catch (Exception ex) {
436 <            unexpectedException();
437 <        }
459 >        } catch (IllegalMonitorStateException success) {}
460      }
461  
462      /**
463       * awaitNanos without a signal times out
464       */
465 <    public void testAwaitNanos_Timeout() {
466 <        final Mutex lock = new Mutex();
467 <        final AbstractQueuedSynchronizer.ConditionObject c = lock.newCondition();
468 <        try {
469 <            lock.acquireExclusiveUninterruptibly(1);
470 <            long t = c.awaitNanos(100);
471 <            assertTrue(t <= 0);
450 <            lock.releaseExclusive(1);
451 <        }
452 <        catch (Exception ex) {
453 <            unexpectedException();
454 <        }
465 >    public void testAwaitNanos_Timeout() throws InterruptedException {
466 >        final Mutex sync = new Mutex();
467 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
468 >        sync.acquire(1);
469 >        long t = c.awaitNanos(100);
470 >        assertTrue(t <= 0);
471 >        sync.release(1);
472      }
473  
474      /**
475 <     *  timed await without a signal times out
476 <     */
477 <    public void testAwait_Timeout() {
478 <        final Mutex lock = new Mutex();
479 <        final AbstractQueuedSynchronizer.ConditionObject c = lock.newCondition();
480 <        try {
481 <            lock.acquireExclusiveUninterruptibly(1);
482 <            assertFalse(c.await(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
466 <            lock.releaseExclusive(1);
467 <        }
468 <        catch (Exception ex) {
469 <            unexpectedException();
470 <        }
475 >     *  Timed await without a signal times out
476 >     */
477 >    public void testAwait_Timeout() throws InterruptedException {
478 >        final Mutex sync = new Mutex();
479 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
480 >        sync.acquire(1);
481 >        assertFalse(c.await(SHORT_DELAY_MS, MILLISECONDS));
482 >        sync.release(1);
483      }
484  
485      /**
486       * awaitUntil without a signal times out
487       */
488 <    public void testAwaitUntil_Timeout() {
489 <        final Mutex lock = new Mutex();
490 <        final AbstractQueuedSynchronizer.ConditionObject c = lock.newCondition();
491 <        try {
492 <            lock.acquireExclusiveUninterruptibly(1);
493 <            java.util.Date d = new java.util.Date();
494 <            assertFalse(c.awaitUntil(new java.util.Date(d.getTime() + 10)));
483 <            lock.releaseExclusive(1);
484 <        }
485 <        catch (Exception ex) {
486 <            unexpectedException();
487 <        }
488 >    public void testAwaitUntil_Timeout() throws InterruptedException {
489 >        final Mutex sync = new Mutex();
490 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
491 >        sync.acquire(1);
492 >        java.util.Date d = new java.util.Date();
493 >        assertFalse(c.awaitUntil(new java.util.Date(d.getTime() + 10)));
494 >        sync.release(1);
495      }
496  
497      /**
498       * await returns when signalled
499       */
500 <    public void testAwait() {
501 <        final Mutex lock = new Mutex();
502 <        final AbstractQueuedSynchronizer.ConditionObject c = lock.newCondition();
503 <        Thread t = new Thread(new Runnable() {
504 <                public void run() {
505 <                    try {
506 <                        lock.acquireExclusiveUninterruptibly(1);
507 <                        c.await();
508 <                        lock.releaseExclusive(1);
502 <                    }
503 <                    catch(InterruptedException e) {
504 <                        threadUnexpectedException();
505 <                    }
506 <                }
507 <            });
500 >    public void testAwait() throws InterruptedException {
501 >        final Mutex sync = new Mutex();
502 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
503 >        Thread t = new Thread(new CheckedRunnable() {
504 >            public void realRun() throws InterruptedException {
505 >                sync.acquire(1);
506 >                c.await();
507 >                sync.release(1);
508 >            }});
509  
510 <        try {
511 <            t.start();
512 <            Thread.sleep(SHORT_DELAY_MS);
513 <            lock.acquireExclusiveUninterruptibly(1);
514 <            c.signal();
515 <            lock.releaseExclusive(1);
516 <            t.join(SHORT_DELAY_MS);
516 <            assertFalse(t.isAlive());
517 <        }
518 <        catch (Exception ex) {
519 <            unexpectedException();
520 <        }
510 >        t.start();
511 >        Thread.sleep(SHORT_DELAY_MS);
512 >        sync.acquire(1);
513 >        c.signal();
514 >        sync.release(1);
515 >        t.join(SHORT_DELAY_MS);
516 >        assertFalse(t.isAlive());
517      }
518  
519  
# Line 526 | Line 522 | public class AbstractQueuedSynchronizerT
522       * hasWaiters throws NPE if null
523       */
524      public void testHasWaitersNPE() {
525 <        final Mutex lock = new Mutex();
525 >        final Mutex sync = new Mutex();
526          try {
527 <            lock.hasWaiters(null);
527 >            sync.hasWaiters(null);
528              shouldThrow();
529 <        } catch (NullPointerException success) {
534 <        } catch (Exception ex) {
535 <            unexpectedException();
536 <        }
529 >        } catch (NullPointerException success) {}
530      }
531  
532      /**
533       * getWaitQueueLength throws NPE if null
534       */
535      public void testGetWaitQueueLengthNPE() {
536 <        final Mutex lock = new Mutex();
536 >        final Mutex sync = new Mutex();
537          try {
538 <            lock.getWaitQueueLength(null);
538 >            sync.getWaitQueueLength(null);
539              shouldThrow();
540 <        } catch (NullPointerException success) {
548 <        } catch (Exception ex) {
549 <            unexpectedException();
550 <        }
540 >        } catch (NullPointerException success) {}
541      }
542  
543  
# Line 555 | Line 545 | public class AbstractQueuedSynchronizerT
545       * getWaitingThreads throws NPE if null
546       */
547      public void testGetWaitingThreadsNPE() {
548 <        final Mutex lock = new Mutex();
548 >        final Mutex sync = new Mutex();
549          try {
550 <            lock.getWaitingThreads(null);
550 >            sync.getWaitingThreads(null);
551              shouldThrow();
552 <        } catch (NullPointerException success) {
563 <        } catch (Exception ex) {
564 <            unexpectedException();
565 <        }
552 >        } catch (NullPointerException success) {}
553      }
554  
555  
# Line 570 | Line 557 | public class AbstractQueuedSynchronizerT
557       * hasWaiters throws IAE if not owned
558       */
559      public void testHasWaitersIAE() {
560 <        final Mutex lock = new Mutex();
561 <        final AbstractQueuedSynchronizer.ConditionObject c = (lock.newCondition());
562 <        final Mutex lock2 = new Mutex();
560 >        final Mutex sync = new Mutex();
561 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
562 >        final Mutex sync2 = new Mutex();
563          try {
564 <            lock2.hasWaiters(c);
564 >            sync2.hasWaiters(c);
565              shouldThrow();
566 <        } catch (IllegalArgumentException success) {
580 <        } catch (Exception ex) {
581 <            unexpectedException();
582 <        }
566 >        } catch (IllegalArgumentException success) {}
567      }
568  
569      /**
570 <     * hasWaiters throws IMSE if not locked
570 >     * hasWaiters throws IMSE if not synced
571       */
572      public void testHasWaitersIMSE() {
573 <        final Mutex lock = new Mutex();
574 <        final AbstractQueuedSynchronizer.ConditionObject c = (lock.newCondition());
573 >        final Mutex sync = new Mutex();
574 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
575          try {
576 <            lock.hasWaiters(c);
576 >            sync.hasWaiters(c);
577              shouldThrow();
578 <        } catch (IllegalMonitorStateException success) {
595 <        } catch (Exception ex) {
596 <            unexpectedException();
597 <        }
578 >        } catch (IllegalMonitorStateException success) {}
579      }
580  
581  
# Line 602 | Line 583 | public class AbstractQueuedSynchronizerT
583       * getWaitQueueLength throws IAE if not owned
584       */
585      public void testGetWaitQueueLengthIAE() {
586 <        final Mutex lock = new Mutex();
587 <        final AbstractQueuedSynchronizer.ConditionObject c = (lock.newCondition());
588 <        final Mutex lock2 = new Mutex();
586 >        final Mutex sync = new Mutex();
587 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
588 >        final Mutex sync2 = new Mutex();
589          try {
590 <            lock2.getWaitQueueLength(c);
590 >            sync2.getWaitQueueLength(c);
591              shouldThrow();
592 <        } catch (IllegalArgumentException success) {
612 <        } catch (Exception ex) {
613 <            unexpectedException();
614 <        }
592 >        } catch (IllegalArgumentException success) {}
593      }
594  
595      /**
596 <     * getWaitQueueLength throws IMSE if not locked
596 >     * getWaitQueueLength throws IMSE if not synced
597       */
598      public void testGetWaitQueueLengthIMSE() {
599 <        final Mutex lock = new Mutex();
600 <        final AbstractQueuedSynchronizer.ConditionObject c = (lock.newCondition());
599 >        final Mutex sync = new Mutex();
600 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
601          try {
602 <            lock.getWaitQueueLength(c);
602 >            sync.getWaitQueueLength(c);
603              shouldThrow();
604 <        } catch (IllegalMonitorStateException success) {
627 <        } catch (Exception ex) {
628 <            unexpectedException();
629 <        }
604 >        } catch (IllegalMonitorStateException success) {}
605      }
606  
607  
# Line 634 | Line 609 | public class AbstractQueuedSynchronizerT
609       * getWaitingThreads throws IAE if not owned
610       */
611      public void testGetWaitingThreadsIAE() {
612 <        final Mutex lock = new Mutex();
613 <        final AbstractQueuedSynchronizer.ConditionObject c = (lock.newCondition());
614 <        final Mutex lock2 = new Mutex();        
612 >        final Mutex sync = new Mutex();
613 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
614 >        final Mutex sync2 = new Mutex();
615          try {
616 <            lock2.getWaitingThreads(c);
616 >            sync2.getWaitingThreads(c);
617              shouldThrow();
618 <        } catch (IllegalArgumentException success) {
644 <        } catch (Exception ex) {
645 <            unexpectedException();
646 <        }
618 >        } catch (IllegalArgumentException success) {}
619      }
620  
621      /**
622 <     * getWaitingThreads throws IMSE if not locked
622 >     * getWaitingThreads throws IMSE if not synced
623       */
624      public void testGetWaitingThreadsIMSE() {
625 <        final Mutex lock = new Mutex();
626 <        final AbstractQueuedSynchronizer.ConditionObject c = (lock.newCondition());
625 >        final Mutex sync = new Mutex();
626 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
627          try {
628 <            lock.getWaitingThreads(c);
628 >            sync.getWaitingThreads(c);
629              shouldThrow();
630 <        } catch (IllegalMonitorStateException success) {
659 <        } catch (Exception ex) {
660 <            unexpectedException();
661 <        }
630 >        } catch (IllegalMonitorStateException success) {}
631      }
632  
633  
# Line 666 | Line 635 | public class AbstractQueuedSynchronizerT
635      /**
636       * hasWaiters returns true when a thread is waiting, else false
637       */
638 <    public void testHasWaiters() {
639 <        final Mutex lock = new Mutex();
640 <        final AbstractQueuedSynchronizer.ConditionObject c = lock.newCondition();
641 <        Thread t = new Thread(new Runnable() {
642 <                public void run() {
643 <                    try {
644 <                        lock.acquireExclusiveUninterruptibly(1);
645 <                        threadAssertFalse(lock.hasWaiters(c));
646 <                        threadAssertEquals(0, lock.getWaitQueueLength(c));
647 <                        c.await();
648 <                        lock.releaseExclusive(1);
680 <                    }
681 <                    catch(InterruptedException e) {
682 <                        threadUnexpectedException();
683 <                    }
684 <                }
685 <            });
638 >    public void testHasWaiters() throws InterruptedException {
639 >        final Mutex sync = new Mutex();
640 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
641 >        Thread t = new Thread(new CheckedRunnable() {
642 >            public void realRun() throws InterruptedException {
643 >                sync.acquire(1);
644 >                threadAssertFalse(sync.hasWaiters(c));
645 >                threadAssertEquals(0, sync.getWaitQueueLength(c));
646 >                c.await();
647 >                sync.release(1);
648 >            }});
649  
650 <        try {
651 <            t.start();
652 <            Thread.sleep(SHORT_DELAY_MS);
653 <            lock.acquireExclusiveUninterruptibly(1);
654 <            assertTrue(lock.hasWaiters(c));
655 <            assertEquals(1, lock.getWaitQueueLength(c));
656 <            c.signal();
657 <            lock.releaseExclusive(1);
658 <            Thread.sleep(SHORT_DELAY_MS);
659 <            lock.acquireExclusiveUninterruptibly(1);
660 <            assertFalse(lock.hasWaiters(c));
661 <            assertEquals(0, lock.getWaitQueueLength(c));
662 <            lock.releaseExclusive(1);
663 <            t.join(SHORT_DELAY_MS);
701 <            assertFalse(t.isAlive());
702 <        }
703 <        catch (Exception ex) {
704 <            unexpectedException();
705 <        }
650 >        t.start();
651 >        Thread.sleep(SHORT_DELAY_MS);
652 >        sync.acquire(1);
653 >        assertTrue(sync.hasWaiters(c));
654 >        assertEquals(1, sync.getWaitQueueLength(c));
655 >        c.signal();
656 >        sync.release(1);
657 >        Thread.sleep(SHORT_DELAY_MS);
658 >        sync.acquire(1);
659 >        assertFalse(sync.hasWaiters(c));
660 >        assertEquals(0, sync.getWaitQueueLength(c));
661 >        sync.release(1);
662 >        t.join(SHORT_DELAY_MS);
663 >        assertFalse(t.isAlive());
664      }
665  
666      /**
667       * getWaitQueueLength returns number of waiting threads
668       */
669 <    public void testGetWaitQueueLength() {
670 <        final Mutex lock = new Mutex();
671 <        final AbstractQueuedSynchronizer.ConditionObject c = lock.newCondition();
672 <        Thread t1 = new Thread(new Runnable() {
673 <                public void run() {
674 <                    try {
675 <                        lock.acquireExclusiveUninterruptibly(1);
676 <                        threadAssertFalse(lock.hasWaiters(c));
677 <                        threadAssertEquals(0, lock.getWaitQueueLength(c));
678 <                        c.await();
679 <                        lock.releaseExclusive(1);
680 <                    }
681 <                    catch(InterruptedException e) {
682 <                        threadUnexpectedException();
683 <                    }
684 <                }
685 <            });
686 <
687 <        Thread t2 = new Thread(new Runnable() {
688 <                public void run() {
689 <                    try {
690 <                        lock.acquireExclusiveUninterruptibly(1);
691 <                        threadAssertTrue(lock.hasWaiters(c));
692 <                        threadAssertEquals(1, lock.getWaitQueueLength(c));
693 <                        c.await();
694 <                        lock.releaseExclusive(1);
695 <                    }
696 <                    catch(InterruptedException e) {
697 <                        threadUnexpectedException();
698 <                    }
699 <                }
700 <            });
701 <
702 <        try {
703 <            t1.start();
704 <            Thread.sleep(SHORT_DELAY_MS);
705 <            t2.start();
706 <            Thread.sleep(SHORT_DELAY_MS);
707 <            lock.acquireExclusiveUninterruptibly(1);
750 <            assertTrue(lock.hasWaiters(c));
751 <            assertEquals(2, lock.getWaitQueueLength(c));
752 <            c.signalAll();
753 <            lock.releaseExclusive(1);
754 <            Thread.sleep(SHORT_DELAY_MS);
755 <            lock.acquireExclusiveUninterruptibly(1);
756 <            assertFalse(lock.hasWaiters(c));
757 <            assertEquals(0, lock.getWaitQueueLength(c));
758 <            lock.releaseExclusive(1);
759 <            t1.join(SHORT_DELAY_MS);
760 <            t2.join(SHORT_DELAY_MS);
761 <            assertFalse(t1.isAlive());
762 <            assertFalse(t2.isAlive());
763 <        }
764 <        catch (Exception ex) {
765 <            unexpectedException();
766 <        }
669 >    public void testGetWaitQueueLength() throws InterruptedException {
670 >        final Mutex sync = new Mutex();
671 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
672 >        Thread t1 = new Thread(new CheckedRunnable() {
673 >            public void realRun() throws InterruptedException {
674 >                sync.acquire(1);
675 >                threadAssertFalse(sync.hasWaiters(c));
676 >                threadAssertEquals(0, sync.getWaitQueueLength(c));
677 >                c.await();
678 >                sync.release(1);
679 >            }});
680 >
681 >        Thread t2 = new Thread(new CheckedRunnable() {
682 >            public void realRun() throws InterruptedException {
683 >                sync.acquire(1);
684 >                threadAssertTrue(sync.hasWaiters(c));
685 >                threadAssertEquals(1, sync.getWaitQueueLength(c));
686 >                c.await();
687 >                sync.release(1);
688 >            }});
689 >
690 >        t1.start();
691 >        Thread.sleep(SHORT_DELAY_MS);
692 >        t2.start();
693 >        Thread.sleep(SHORT_DELAY_MS);
694 >        sync.acquire(1);
695 >        assertTrue(sync.hasWaiters(c));
696 >        assertEquals(2, sync.getWaitQueueLength(c));
697 >        c.signalAll();
698 >        sync.release(1);
699 >        Thread.sleep(SHORT_DELAY_MS);
700 >        sync.acquire(1);
701 >        assertFalse(sync.hasWaiters(c));
702 >        assertEquals(0, sync.getWaitQueueLength(c));
703 >        sync.release(1);
704 >        t1.join(SHORT_DELAY_MS);
705 >        t2.join(SHORT_DELAY_MS);
706 >        assertFalse(t1.isAlive());
707 >        assertFalse(t2.isAlive());
708      }
709  
710      /**
711       * getWaitingThreads returns only and all waiting threads
712       */
713 <    public void testGetWaitingThreads() {
714 <        final Mutex lock = new Mutex();
715 <        final AbstractQueuedSynchronizer.ConditionObject c = lock.newCondition();
716 <        Thread t1 = new Thread(new Runnable() {
717 <                public void run() {
718 <                    try {
719 <                        lock.acquireExclusiveUninterruptibly(1);
720 <                        threadAssertTrue(lock.getWaitingThreads(c).isEmpty());
721 <                        c.await();
722 <                        lock.releaseExclusive(1);
723 <                    }
724 <                    catch(InterruptedException e) {
725 <                        threadUnexpectedException();
726 <                    }
727 <                }
728 <            });
729 <
730 <        Thread t2 = new Thread(new Runnable() {
731 <                public void run() {
732 <                    try {
733 <                        lock.acquireExclusiveUninterruptibly(1);
734 <                        threadAssertFalse(lock.getWaitingThreads(c).isEmpty());
735 <                        c.await();
736 <                        lock.releaseExclusive(1);
737 <                    }
738 <                    catch(InterruptedException e) {
739 <                        threadUnexpectedException();
740 <                    }
741 <                }
742 <            });
743 <
744 <        try {
745 <            lock.acquireExclusiveUninterruptibly(1);
746 <            assertTrue(lock.getWaitingThreads(c).isEmpty());
747 <            lock.releaseExclusive(1);
748 <            t1.start();
749 <            Thread.sleep(SHORT_DELAY_MS);
750 <            t2.start();
751 <            Thread.sleep(SHORT_DELAY_MS);
752 <            lock.acquireExclusiveUninterruptibly(1);
753 <            assertTrue(lock.hasWaiters(c));
813 <            assertTrue(lock.getWaitingThreads(c).contains(t1));
814 <            assertTrue(lock.getWaitingThreads(c).contains(t2));
815 <            c.signalAll();
816 <            lock.releaseExclusive(1);
817 <            Thread.sleep(SHORT_DELAY_MS);
818 <            lock.acquireExclusiveUninterruptibly(1);
819 <            assertFalse(lock.hasWaiters(c));
820 <            assertTrue(lock.getWaitingThreads(c).isEmpty());
821 <            lock.releaseExclusive(1);
822 <            t1.join(SHORT_DELAY_MS);
823 <            t2.join(SHORT_DELAY_MS);
824 <            assertFalse(t1.isAlive());
825 <            assertFalse(t2.isAlive());
826 <        }
827 <        catch (Exception ex) {
828 <            unexpectedException();
829 <        }
713 >    public void testGetWaitingThreads() throws InterruptedException {
714 >        final Mutex sync = new Mutex();
715 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
716 >        Thread t1 = new Thread(new CheckedRunnable() {
717 >            public void realRun() throws InterruptedException {
718 >                sync.acquire(1);
719 >                threadAssertTrue(sync.getWaitingThreads(c).isEmpty());
720 >                c.await();
721 >                sync.release(1);
722 >            }});
723 >
724 >        Thread t2 = new Thread(new CheckedRunnable() {
725 >            public void realRun() throws InterruptedException {
726 >                sync.acquire(1);
727 >                threadAssertFalse(sync.getWaitingThreads(c).isEmpty());
728 >                c.await();
729 >                sync.release(1);
730 >            }});
731 >
732 >        sync.acquire(1);
733 >        assertTrue(sync.getWaitingThreads(c).isEmpty());
734 >        sync.release(1);
735 >        t1.start();
736 >        Thread.sleep(SHORT_DELAY_MS);
737 >        t2.start();
738 >        Thread.sleep(SHORT_DELAY_MS);
739 >        sync.acquire(1);
740 >        assertTrue(sync.hasWaiters(c));
741 >        assertTrue(sync.getWaitingThreads(c).contains(t1));
742 >        assertTrue(sync.getWaitingThreads(c).contains(t2));
743 >        c.signalAll();
744 >        sync.release(1);
745 >        Thread.sleep(SHORT_DELAY_MS);
746 >        sync.acquire(1);
747 >        assertFalse(sync.hasWaiters(c));
748 >        assertTrue(sync.getWaitingThreads(c).isEmpty());
749 >        sync.release(1);
750 >        t1.join(SHORT_DELAY_MS);
751 >        t2.join(SHORT_DELAY_MS);
752 >        assertFalse(t1.isAlive());
753 >        assertFalse(t2.isAlive());
754      }
755  
756  
# Line 834 | Line 758 | public class AbstractQueuedSynchronizerT
758      /**
759       * awaitUninterruptibly doesn't abort on interrupt
760       */
761 <    public void testAwaitUninterruptibly() {
762 <        final Mutex lock = new Mutex();
763 <        final AbstractQueuedSynchronizer.ConditionObject c = lock.newCondition();
764 <        Thread t = new Thread(new Runnable() {
765 <                public void run() {
766 <                    lock.acquireExclusiveUninterruptibly(1);
767 <                    c.awaitUninterruptibly();
768 <                    lock.releaseExclusive(1);
769 <                }
846 <            });
761 >    public void testAwaitUninterruptibly() throws InterruptedException {
762 >        final Mutex sync = new Mutex();
763 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
764 >        Thread t = new Thread(new CheckedRunnable() {
765 >            public void realRun() {
766 >                sync.acquire(1);
767 >                c.awaitUninterruptibly();
768 >                sync.release(1);
769 >            }});
770  
771 <        try {
772 <            t.start();
773 <            Thread.sleep(SHORT_DELAY_MS);
774 <            t.interrupt();
775 <            lock.acquireExclusiveUninterruptibly(1);
776 <            c.signal();
777 <            lock.releaseExclusive(1);
778 <            assert(t.isInterrupted());
856 <            t.join(SHORT_DELAY_MS);
857 <            assertFalse(t.isAlive());
858 <        }
859 <        catch (Exception ex) {
860 <            unexpectedException();
861 <        }
771 >        t.start();
772 >        Thread.sleep(SHORT_DELAY_MS);
773 >        t.interrupt();
774 >        sync.acquire(1);
775 >        c.signal();
776 >        sync.release(1);
777 >        t.join(SHORT_DELAY_MS);
778 >        assertFalse(t.isAlive());
779      }
780  
781      /**
782       * await is interruptible
783       */
784 <    public void testAwait_Interrupt() {
785 <        final Mutex lock = new Mutex();
786 <        final AbstractQueuedSynchronizer.ConditionObject c = lock.newCondition();
787 <        Thread t = new Thread(new Runnable() {
788 <                public void run() {
789 <                    try {
790 <                        lock.acquireExclusiveUninterruptibly(1);
791 <                        c.await();
875 <                        lock.releaseExclusive(1);
876 <                        threadShouldThrow();
877 <                    }
878 <                    catch(InterruptedException success) {
879 <                    }
880 <                }
881 <            });
784 >    public void testAwait_Interrupt() throws InterruptedException {
785 >        final Mutex sync = new Mutex();
786 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
787 >        Thread t = new Thread(new CheckedInterruptedRunnable() {
788 >            public void realRun() throws InterruptedException {
789 >                sync.acquire(1);
790 >                c.await();
791 >            }});
792  
793 <        try {
794 <            t.start();
795 <            Thread.sleep(SHORT_DELAY_MS);
796 <            t.interrupt();
797 <            t.join(SHORT_DELAY_MS);
888 <            assertFalse(t.isAlive());
889 <        }
890 <        catch (Exception ex) {
891 <            unexpectedException();
892 <        }
793 >        t.start();
794 >        Thread.sleep(SHORT_DELAY_MS);
795 >        t.interrupt();
796 >        t.join(SHORT_DELAY_MS);
797 >        assertFalse(t.isAlive());
798      }
799  
800      /**
801       * awaitNanos is interruptible
802       */
803 <    public void testAwaitNanos_Interrupt() {
804 <        final Mutex lock = new Mutex();
805 <        final AbstractQueuedSynchronizer.ConditionObject c = lock.newCondition();
806 <        Thread t = new Thread(new Runnable() {
807 <                public void run() {
808 <                    try {
809 <                        lock.acquireExclusiveUninterruptibly(1);
810 <                        c.awaitNanos(1000 * 1000 * 1000); // 1 sec
906 <                        lock.releaseExclusive(1);
907 <                        threadShouldThrow();
908 <                    }
909 <                    catch(InterruptedException success) {
910 <                    }
911 <                }
912 <            });
803 >    public void testAwaitNanos_Interrupt() throws InterruptedException {
804 >        final Mutex sync = new Mutex();
805 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
806 >        Thread t = new Thread(new CheckedInterruptedRunnable() {
807 >            public void realRun() throws InterruptedException {
808 >                sync.acquire(1);
809 >                c.awaitNanos(LONG_DELAY_MS * 1000L * 1000L);
810 >            }});
811  
812 <        try {
813 <            t.start();
814 <            Thread.sleep(SHORT_DELAY_MS);
815 <            t.interrupt();
816 <            t.join(SHORT_DELAY_MS);
919 <            assertFalse(t.isAlive());
920 <        }
921 <        catch (Exception ex) {
922 <            unexpectedException();
923 <        }
812 >        t.start();
813 >        Thread.sleep(SHORT_DELAY_MS);
814 >        t.interrupt();
815 >        t.join(SHORT_DELAY_MS);
816 >        assertFalse(t.isAlive());
817      }
818  
819      /**
820       * awaitUntil is interruptible
821       */
822 <    public void testAwaitUntil_Interrupt() {
823 <        final Mutex lock = new Mutex();
824 <        final AbstractQueuedSynchronizer.ConditionObject c = lock.newCondition();
825 <        Thread t = new Thread(new Runnable() {
826 <                public void run() {
827 <                    try {
828 <                        lock.acquireExclusiveUninterruptibly(1);
829 <                        java.util.Date d = new java.util.Date();
830 <                        c.awaitUntil(new java.util.Date(d.getTime() + 10000));
938 <                        lock.releaseExclusive(1);
939 <                        threadShouldThrow();
940 <                    }
941 <                    catch(InterruptedException success) {
942 <                    }
943 <                }
944 <            });
822 >    public void testAwaitUntil_Interrupt() throws InterruptedException {
823 >        final Mutex sync = new Mutex();
824 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
825 >        Thread t = new Thread(new CheckedInterruptedRunnable() {
826 >            public void realRun() throws InterruptedException {
827 >                sync.acquire(1);
828 >                java.util.Date d = new java.util.Date();
829 >                c.awaitUntil(new java.util.Date(d.getTime() + 10000));
830 >            }});
831  
832 <        try {
833 <            t.start();
834 <            Thread.sleep(SHORT_DELAY_MS);
835 <            t.interrupt();
836 <            t.join(SHORT_DELAY_MS);
951 <            assertFalse(t.isAlive());
952 <        }
953 <        catch (Exception ex) {
954 <            unexpectedException();
955 <        }
832 >        t.start();
833 >        Thread.sleep(SHORT_DELAY_MS);
834 >        t.interrupt();
835 >        t.join(SHORT_DELAY_MS);
836 >        assertFalse(t.isAlive());
837      }
838  
839      /**
840       * signalAll wakes up all threads
841       */
842 <    public void testSignalAll() {
843 <        final Mutex lock = new Mutex();
844 <        final AbstractQueuedSynchronizer.ConditionObject c = lock.newCondition();
845 <        Thread t1 = new Thread(new Runnable() {
846 <                public void run() {
847 <                    try {
848 <                        lock.acquireExclusiveUninterruptibly(1);
849 <                        c.await();
850 <                        lock.releaseExclusive(1);
851 <                    }
852 <                    catch(InterruptedException e) {
853 <                        threadUnexpectedException();
854 <                    }
855 <                }
856 <            });
857 <
858 <        Thread t2 = new Thread(new Runnable() {
859 <                public void run() {
860 <                    try {
861 <                        lock.acquireExclusiveUninterruptibly(1);
862 <                        c.await();
863 <                        lock.releaseExclusive(1);
864 <                    }
865 <                    catch(InterruptedException e) {
866 <                        threadUnexpectedException();
867 <                    }
868 <                }
988 <            });
989 <
990 <        try {
991 <            t1.start();
992 <            t2.start();
993 <            Thread.sleep(SHORT_DELAY_MS);
994 <            lock.acquireExclusiveUninterruptibly(1);
995 <            c.signalAll();
996 <            lock.releaseExclusive(1);
997 <            t1.join(SHORT_DELAY_MS);
998 <            t2.join(SHORT_DELAY_MS);
999 <            assertFalse(t1.isAlive());
1000 <            assertFalse(t2.isAlive());
1001 <        }
1002 <        catch (Exception ex) {
1003 <            unexpectedException();
1004 <        }
842 >    public void testSignalAll() throws InterruptedException {
843 >        final Mutex sync = new Mutex();
844 >        final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
845 >        Thread t1 = new Thread(new CheckedRunnable() {
846 >            public void realRun() throws InterruptedException {
847 >                sync.acquire(1);
848 >                c.await();
849 >                sync.release(1);
850 >            }});
851 >
852 >        Thread t2 = new Thread(new CheckedRunnable() {
853 >            public void realRun() throws InterruptedException {
854 >                sync.acquire(1);
855 >                c.await();
856 >                sync.release(1);
857 >            }});
858 >
859 >        t1.start();
860 >        t2.start();
861 >        Thread.sleep(SHORT_DELAY_MS);
862 >        sync.acquire(1);
863 >        c.signalAll();
864 >        sync.release(1);
865 >        t1.join(SHORT_DELAY_MS);
866 >        t2.join(SHORT_DELAY_MS);
867 >        assertFalse(t1.isAlive());
868 >        assertFalse(t2.isAlive());
869      }
870  
871  
# Line 1009 | Line 873 | public class AbstractQueuedSynchronizerT
873       * toString indicates current state
874       */
875      public void testToString() {
876 <        Mutex lock = new Mutex();
877 <        String us = lock.toString();
876 >        Mutex sync = new Mutex();
877 >        String us = sync.toString();
878          assertTrue(us.indexOf("State = 0") >= 0);
879 <        lock.acquireExclusiveUninterruptibly(1);
880 <        String ls = lock.toString();
879 >        sync.acquire(1);
880 >        String ls = sync.toString();
881          assertTrue(ls.indexOf("State = 1") >= 0);
882      }
883  
884      /**
885       * A serialized AQS deserializes with current state
886       */
887 <    public void testSerialization() {
887 >    public void testSerialization() throws Exception {
888          Mutex l = new Mutex();
889 <        l.acquireExclusiveUninterruptibly(1);
890 <        assertTrue(l.isLocked());
889 >        l.acquire(1);
890 >        assertTrue(l.isHeldExclusively());
891  
892 <        try {
893 <            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
894 <            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
895 <            out.writeObject(l);
896 <            out.close();
897 <
898 <            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
899 <            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
900 <            Mutex r = (Mutex) in.readObject();
1037 <            assertTrue(r.isLocked());
1038 <        } catch(Exception e){
1039 <            e.printStackTrace();
1040 <            unexpectedException();
1041 <        }
892 >        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
893 >        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
894 >        out.writeObject(l);
895 >        out.close();
896 >
897 >        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
898 >        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
899 >        Mutex r = (Mutex) in.readObject();
900 >        assertTrue(r.isHeldExclusively());
901      }
902  
903  
# Line 1046 | Line 905 | public class AbstractQueuedSynchronizerT
905       * tryReleaseShared setting state changes getState
906       */
907      public void testGetStateWithReleaseShared() {
908 <        final BooleanLatch l = new BooleanLatch();
909 <        assertFalse(l.isSignalled());
910 <        l.releaseShared(0);
911 <        assertTrue(l.isSignalled());
908 >        final BooleanLatch l = new BooleanLatch();
909 >        assertFalse(l.isSignalled());
910 >        l.releaseShared(0);
911 >        assertTrue(l.isSignalled());
912      }
913  
914      /**
915 <     * release and has no effect when already signalled
915 >     * releaseShared has no effect when already signalled
916       */
917      public void testReleaseShared() {
918 <        final BooleanLatch l = new BooleanLatch();
919 <        assertFalse(l.isSignalled());
920 <        l.releaseShared(0);
921 <        assertTrue(l.isSignalled());
922 <        l.releaseShared(0);
923 <        assertTrue(l.isSignalled());
918 >        final BooleanLatch l = new BooleanLatch();
919 >        assertFalse(l.isSignalled());
920 >        l.releaseShared(0);
921 >        assertTrue(l.isSignalled());
922 >        l.releaseShared(0);
923 >        assertTrue(l.isSignalled());
924      }
925  
926      /**
927       * acquireSharedInterruptibly returns after release, but not before
928       */
929 <    public void testAcquireSharedInterruptibly() {
930 <        final BooleanLatch l = new BooleanLatch();
929 >    public void testAcquireSharedInterruptibly() throws InterruptedException {
930 >        final BooleanLatch l = new BooleanLatch();
931  
932 <        Thread t = new Thread(new Runnable() {
933 <                public void run() {
934 <                    try {
935 <                        threadAssertFalse(l.isSignalled());
936 <                        l.acquireSharedInterruptibly(0);
937 <                        threadAssertTrue(l.isSignalled());
938 <                    } catch(InterruptedException e){
939 <                        threadUnexpectedException();
940 <                    }
941 <                }
942 <            });
943 <        try {
944 <            t.start();
1086 <            assertFalse(l.isSignalled());
1087 <            Thread.sleep(SHORT_DELAY_MS);
1088 <            l.releaseShared(0);
1089 <            assertTrue(l.isSignalled());
1090 <            t.join();
1091 <        } catch (InterruptedException e){
1092 <            unexpectedException();
1093 <        }
932 >        Thread t = new Thread(new CheckedRunnable() {
933 >            public void realRun() throws InterruptedException {
934 >                threadAssertFalse(l.isSignalled());
935 >                l.acquireSharedInterruptibly(0);
936 >                threadAssertTrue(l.isSignalled());
937 >            }});
938 >
939 >        t.start();
940 >        assertFalse(l.isSignalled());
941 >        Thread.sleep(SHORT_DELAY_MS);
942 >        l.releaseShared(0);
943 >        assertTrue(l.isSignalled());
944 >        t.join();
945      }
946 <    
946 >
947  
948      /**
949       * acquireSharedTimed returns after release
950       */
951 <    public void testAsquireSharedTimed() {
952 <        final BooleanLatch l = new BooleanLatch();
951 >    public void testAsquireSharedTimed() throws InterruptedException {
952 >        final BooleanLatch l = new BooleanLatch();
953  
954 <        Thread t = new Thread(new Runnable() {
955 <                public void run() {
956 <                    try {
957 <                        threadAssertFalse(l.isSignalled());
958 <                        threadAssertTrue(l.acquireSharedNanos(0, MEDIUM_DELAY_MS* 1000 * 1000));
959 <                        threadAssertTrue(l.isSignalled());
960 <
961 <                    } catch(InterruptedException e){
962 <                        threadUnexpectedException();
963 <                    }
964 <                }
965 <            });
966 <        try {
1116 <            t.start();
1117 <            assertFalse(l.isSignalled());
1118 <            Thread.sleep(SHORT_DELAY_MS);
1119 <            l.releaseShared(0);
1120 <            assertTrue(l.isSignalled());
1121 <            t.join();
1122 <        } catch (InterruptedException e){
1123 <            unexpectedException();
1124 <        }
954 >        Thread t = new Thread(new CheckedRunnable() {
955 >            public void realRun() throws InterruptedException {
956 >                threadAssertFalse(l.isSignalled());
957 >                threadAssertTrue(l.tryAcquireSharedNanos(0, MEDIUM_DELAY_MS * 1000L * 1000L));
958 >                threadAssertTrue(l.isSignalled());
959 >            }});
960 >
961 >        t.start();
962 >        assertFalse(l.isSignalled());
963 >        Thread.sleep(SHORT_DELAY_MS);
964 >        l.releaseShared(0);
965 >        assertTrue(l.isSignalled());
966 >        t.join();
967      }
968 <    
968 >
969      /**
970       * acquireSharedInterruptibly throws IE if interrupted before released
971       */
972 <    public void testAcquireSharedInterruptibly_InterruptedException() {
972 >    public void testAcquireSharedInterruptibly_InterruptedException() throws InterruptedException {
973          final BooleanLatch l = new BooleanLatch();
974 <        Thread t = new Thread(new Runnable() {
975 <                public void run() {
976 <                    try {
977 <                        threadAssertFalse(l.isSignalled());
978 <                        l.acquireSharedInterruptibly(0);
979 <                        threadShouldThrow();
980 <                    } catch(InterruptedException success){}
981 <                }
982 <            });
983 <        t.start();
1142 <        try {
1143 <            assertFalse(l.isSignalled());
1144 <            t.interrupt();
1145 <            t.join();
1146 <        } catch (InterruptedException e){
1147 <            unexpectedException();
1148 <        }
974 >        Thread t = new Thread(new CheckedInterruptedRunnable() {
975 >            public void realRun() throws InterruptedException {
976 >                threadAssertFalse(l.isSignalled());
977 >                l.acquireSharedInterruptibly(0);
978 >            }});
979 >
980 >        t.start();
981 >        assertFalse(l.isSignalled());
982 >        t.interrupt();
983 >        t.join();
984      }
985  
986      /**
987       * acquireSharedTimed throws IE if interrupted before released
988       */
989 <    public void testAcquireSharedNanos_InterruptedException() {
989 >    public void testAcquireSharedNanos_InterruptedException() throws InterruptedException {
990          final BooleanLatch l = new BooleanLatch();
991 <        Thread t = new Thread(new Runnable() {
992 <                public void run() {
993 <                    try {
994 <                        threadAssertFalse(l.isSignalled());
995 <                        l.acquireSharedNanos(0, SMALL_DELAY_MS* 1000 * 1000);
996 <                        threadShouldThrow();                        
1162 <                    } catch(InterruptedException success){}
1163 <                }
1164 <            });
991 >        Thread t = new Thread(new CheckedInterruptedRunnable() {
992 >            public void realRun() throws InterruptedException {
993 >                threadAssertFalse(l.isSignalled());
994 >                l.tryAcquireSharedNanos(0, SMALL_DELAY_MS * 1000L * 1000L);
995 >            }});
996 >
997          t.start();
998 <        try {
999 <            Thread.sleep(SHORT_DELAY_MS);
1000 <            assertFalse(l.isSignalled());
1001 <            t.interrupt();
1170 <            t.join();
1171 <        } catch (InterruptedException e){
1172 <            unexpectedException();
1173 <        }
998 >        Thread.sleep(SHORT_DELAY_MS);
999 >        assertFalse(l.isSignalled());
1000 >        t.interrupt();
1001 >        t.join();
1002      }
1003  
1004      /**
1005       * acquireSharedTimed times out if not released before timeout
1006       */
1007 <    public void testAcquireSharedNanos_Timeout() {
1007 >    public void testAcquireSharedNanos_Timeout() throws InterruptedException {
1008          final BooleanLatch l = new BooleanLatch();
1009 <        Thread t = new Thread(new Runnable() {
1010 <                public void run() {
1011 <                    try {
1012 <                        threadAssertFalse(l.isSignalled());
1013 <                        threadAssertFalse(l.acquireSharedNanos(0, SMALL_DELAY_MS* 1000 * 1000));
1014 <                    } catch(InterruptedException ie){
1187 <                        threadUnexpectedException();
1188 <                    }
1189 <                }
1190 <            });
1009 >        Thread t = new Thread(new CheckedRunnable() {
1010 >            public void realRun() throws InterruptedException {
1011 >                threadAssertFalse(l.isSignalled());
1012 >                threadAssertFalse(l.tryAcquireSharedNanos(0, SMALL_DELAY_MS * 1000L * 1000L));
1013 >            }});
1014 >
1015          t.start();
1016 <        try {
1017 <            Thread.sleep(SHORT_DELAY_MS);
1018 <            assertFalse(l.isSignalled());
1195 <            t.join();
1196 <        } catch (InterruptedException e){
1197 <            unexpectedException();
1198 <        }
1016 >        Thread.sleep(SHORT_DELAY_MS);
1017 >        assertFalse(l.isSignalled());
1018 >        t.join();
1019      }
1020  
1201    
1021   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines