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

Comparing jsr166/src/test/tck/LockSupportTest.java (file contents):
Revision 1.15 by jsr166, Mon Oct 4 20:15:16 2010 UTC vs.
Revision 1.23 by jsr166, Sat May 28 22:21:58 2011 UTC

# Line 2 | Line 2
2   * Written by Doug Lea and Martin Buchholz with assistance from
3   * members of JCP JSR-166 Expert Group and released to the public
4   * domain, as explained at
5 < * http://creativecommons.org/licenses/publicdomain
5 > * http://creativecommons.org/publicdomain/zero/1.0/
6   * Other contributors include Andrew Wright, Jeffrey Hayes,
7   * Pat Fisher, Mike Judd.
8   */
9  
10   import junit.framework.*;
11 < import java.util.*;
12 < import java.util.concurrent.*;
11 > import java.util.concurrent.CountDownLatch;
12   import java.util.concurrent.atomic.AtomicBoolean;
13 < import java.util.concurrent.locks.*;
13 > import java.util.concurrent.locks.LockSupport;
14 > import static java.util.concurrent.TimeUnit.MILLISECONDS;
15  
16   public class LockSupportTest extends JSR166TestCase {
17      public static void main(String[] args) {
# Line 23 | Line 23 | public class LockSupportTest extends JSR
23      }
24  
25      /**
26 <     * park is released by subsequent unpark
26 >     * Returns the blocker object used by tests in this file.
27 >     * Any old object will do; we'll return a convenient one.
28       */
29 <    public void testParkBeforeUnpark() throws InterruptedException {
30 <        final CountDownLatch threadStarted = new CountDownLatch(1);
30 <        Thread t = new Thread(new CheckedRunnable() {
31 <            public void realRun() {
32 <                threadStarted.countDown();
33 <                LockSupport.park();
34 <            }});
35 <
36 <        t.start();
37 <        threadStarted.await();
38 <        Thread.sleep(SHORT_DELAY_MS);
39 <        LockSupport.unpark(t);
40 <        joinWith(t);
29 >    static Object theBlocker() {
30 >        return LockSupportTest.class;
31      }
32  
33 <    /**
34 <     * parkUntil is released by subsequent unpark
35 <     */
36 <    public void testParkUntilBeforeUnpark() throws InterruptedException {
37 <        final CountDownLatch threadStarted = new CountDownLatch(1);
38 <        Thread t = new Thread(new CheckedRunnable() {
39 <            public void realRun() {
40 <                long d = new Date().getTime() + LONG_DELAY_MS;
41 <                long nanos = LONG_DELAY_MS * 1000L * 1000L;
42 <                long t0 = System.nanoTime();
43 <                threadStarted.countDown();
44 <                LockSupport.parkUntil(d);
45 <                assertTrue(System.nanoTime() - t0 < nanos);
46 <            }});
47 <
48 <        t.start();
49 <        threadStarted.await();
50 <        Thread.sleep(SHORT_DELAY_MS);
51 <        LockSupport.unpark(t);
52 <        joinWith(t);
33 >    enum ParkMethod {
34 >        park() {
35 >            void park() {
36 >                LockSupport.park();
37 >            }
38 >            void park(long millis) {
39 >                throw new UnsupportedOperationException();
40 >            }
41 >        },
42 >        parkUntil() {
43 >            void park(long millis) {
44 >                LockSupport.parkUntil(deadline(millis));
45 >            }
46 >        },
47 >        parkNanos() {
48 >            void park(long millis) {
49 >                LockSupport.parkNanos(MILLISECONDS.toNanos(millis));
50 >            }
51 >        },
52 >        parkBlocker() {
53 >            void park() {
54 >                LockSupport.park(theBlocker());
55 >            }
56 >            void park(long millis) {
57 >                throw new UnsupportedOperationException();
58 >            }
59 >        },
60 >        parkUntilBlocker() {
61 >            void park(long millis) {
62 >                LockSupport.parkUntil(theBlocker(), deadline(millis));
63 >            }
64 >        },
65 >        parkNanosBlocker() {
66 >            void park(long millis) {
67 >                LockSupport.parkNanos(theBlocker(),
68 >                                      MILLISECONDS.toNanos(millis));
69 >            }
70 >        };
71 >
72 >        void park() { park(2 * LONG_DELAY_MS); }
73 >        abstract void park(long millis);
74 >
75 >        /** Returns a deadline to use with parkUntil. */
76 >        long deadline(long millis) {
77 >            // beware of rounding
78 >            return System.currentTimeMillis() + millis + 1;
79 >        }
80      }
81  
82      /**
83 <     * parkNanos is released by subsequent unpark
83 >     * park is released by subsequent unpark
84       */
85 <    public void testParkNanosBeforeUnpark() throws InterruptedException {
86 <        final CountDownLatch threadStarted = new CountDownLatch(1);
87 <        Thread t = new Thread(new CheckedRunnable() {
85 >    public void testParkBeforeUnpark_park() {
86 >        testParkBeforeUnpark(ParkMethod.park);
87 >    }
88 >    public void testParkBeforeUnpark_parkNanos() {
89 >        testParkBeforeUnpark(ParkMethod.parkNanos);
90 >    }
91 >    public void testParkBeforeUnpark_parkUntil() {
92 >        testParkBeforeUnpark(ParkMethod.parkUntil);
93 >    }
94 >    public void testParkBeforeUnpark_parkBlocker() {
95 >        testParkBeforeUnpark(ParkMethod.parkBlocker);
96 >    }
97 >    public void testParkBeforeUnpark_parkNanosBlocker() {
98 >        testParkBeforeUnpark(ParkMethod.parkNanosBlocker);
99 >    }
100 >    public void testParkBeforeUnpark_parkUntilBlocker() {
101 >        testParkBeforeUnpark(ParkMethod.parkUntilBlocker);
102 >    }
103 >    public void testParkBeforeUnpark(final ParkMethod parkMethod) {
104 >        final CountDownLatch pleaseUnpark = new CountDownLatch(1);
105 >        Thread t = newStartedThread(new CheckedRunnable() {
106              public void realRun() {
107 <                long nanos = LONG_DELAY_MS * 1000L * 1000L;
108 <                long t0 = System.nanoTime();
74 <                threadStarted.countDown();
75 <                LockSupport.parkNanos(nanos);
76 <                assertTrue(System.nanoTime() - t0 < nanos);
107 >                pleaseUnpark.countDown();
108 >                parkMethod.park();
109              }});
110  
111 <        t.start();
80 <        threadStarted.await();
81 <        Thread.sleep(SHORT_DELAY_MS);
111 >        await(pleaseUnpark);
112          LockSupport.unpark(t);
113 <        joinWith(t);
113 >        awaitTermination(t);
114      }
115  
116      /**
117       * park is released by preceding unpark
118       */
119 <    public void testParkAfterUnpark() throws Exception {
120 <        final CountDownLatch threadStarted = new CountDownLatch(1);
91 <        final AtomicBoolean unparked = new AtomicBoolean(false);
92 <        Thread t = new Thread(new CheckedRunnable() {
93 <            public void realRun() throws Exception {
94 <                threadStarted.countDown();
95 <                while (!unparked.get())
96 <                    Thread.yield();
97 <                LockSupport.park();
98 <            }});
99 <
100 <        t.start();
101 <        threadStarted.await();
102 <        LockSupport.unpark(t);
103 <        unparked.set(true);
104 <        joinWith(t);
119 >    public void testParkAfterUnpark_park() {
120 >        testParkAfterUnpark(ParkMethod.park);
121      }
122 <
123 <    /**
108 <     * parkUntil is released by preceding unpark
109 <     */
110 <    public void testParkUntilAfterUnpark() throws Exception {
111 <        final CountDownLatch threadStarted = new CountDownLatch(1);
112 <        final AtomicBoolean unparked = new AtomicBoolean(false);
113 <        Thread t = new Thread(new CheckedRunnable() {
114 <            public void realRun() throws Exception {
115 <                threadStarted.countDown();
116 <                while (!unparked.get())
117 <                    Thread.yield();
118 <                long d = new Date().getTime() + LONG_DELAY_MS;
119 <                long nanos = LONG_DELAY_MS * 1000L * 1000L;
120 <                long t0 = System.nanoTime();
121 <                LockSupport.parkUntil(d);
122 <                assertTrue(System.nanoTime() - t0 < nanos);
123 <            }});
124 <
125 <        t.start();
126 <        threadStarted.await();
127 <        LockSupport.unpark(t);
128 <        unparked.set(true);
129 <        joinWith(t);
122 >    public void testParkAfterUnpark_parkNanos() {
123 >        testParkAfterUnpark(ParkMethod.parkNanos);
124      }
125 <
126 <    /**
127 <     * parkNanos is released by preceding unpark
128 <     */
129 <    public void testParkNanosAfterUnpark() throws Exception {
130 <        final CountDownLatch threadStarted = new CountDownLatch(1);
131 <        final AtomicBoolean unparked = new AtomicBoolean(false);
132 <        Thread t = new Thread(new CheckedRunnable() {
133 <            public void realRun() throws Exception {
134 <                threadStarted.countDown();
135 <                while (!unparked.get())
125 >    public void testParkAfterUnpark_parkUntil() {
126 >        testParkAfterUnpark(ParkMethod.parkUntil);
127 >    }
128 >    public void testParkAfterUnpark_parkBlocker() {
129 >        testParkAfterUnpark(ParkMethod.parkBlocker);
130 >    }
131 >    public void testParkAfterUnpark_parkNanosBlocker() {
132 >        testParkAfterUnpark(ParkMethod.parkNanosBlocker);
133 >    }
134 >    public void testParkAfterUnpark_parkUntilBlocker() {
135 >        testParkAfterUnpark(ParkMethod.parkUntilBlocker);
136 >    }
137 >    public void testParkAfterUnpark(final ParkMethod parkMethod) {
138 >        final CountDownLatch pleaseUnpark = new CountDownLatch(1);
139 >        final AtomicBoolean pleasePark = new AtomicBoolean(false);
140 >        Thread t = newStartedThread(new CheckedRunnable() {
141 >            public void realRun() {
142 >                pleaseUnpark.countDown();
143 >                while (!pleasePark.get())
144                      Thread.yield();
145 <                long nanos = LONG_DELAY_MS * 1000L * 1000L;
144 <                long t0 = System.nanoTime();
145 <                LockSupport.parkNanos(nanos);
146 <                assertTrue(System.nanoTime() - t0 < nanos);
145 >                parkMethod.park();
146              }});
147  
148 <        t.start();
150 <        threadStarted.await();
148 >        await(pleaseUnpark);
149          LockSupport.unpark(t);
150 <        unparked.set(true);
151 <        joinWith(t);
150 >        pleasePark.set(true);
151 >        awaitTermination(t);
152      }
153  
154      /**
155       * park is released by subsequent interrupt
156       */
157 <    public void testParkBeforeInterrupt() throws InterruptedException {
158 <        final CountDownLatch threadStarted = new CountDownLatch(1);
161 <        Thread t = new Thread(new CheckedRunnable() {
162 <            public void realRun() {
163 <                assertFalse(Thread.currentThread().isInterrupted());
164 <                threadStarted.countDown();
165 <                LockSupport.park();
166 <                assertTrue(Thread.currentThread().isInterrupted());
167 <            }});
168 <
169 <        t.start();
170 <        threadStarted.await();
171 <        Thread.sleep(SHORT_DELAY_MS);
172 <        t.interrupt();
173 <        joinWith(t);
157 >    public void testParkBeforeInterrupt_park() {
158 >        testParkBeforeInterrupt(ParkMethod.park);
159      }
160 <
161 <    /**
177 <     * parkUntil is released by subsequent interrupt
178 <     */
179 <    public void testParkUntilBeforeInterrupt() throws InterruptedException {
180 <        final CountDownLatch threadStarted = new CountDownLatch(1);
181 <        Thread t = new Thread(new CheckedRunnable() {
182 <            public void realRun() {
183 <                long d = new Date().getTime() + LONG_DELAY_MS;
184 <                long nanos = LONG_DELAY_MS * 1000L * 1000L;
185 <                long t0 = System.nanoTime();
186 <                threadStarted.countDown();
187 <                LockSupport.parkUntil(d);
188 <                assertTrue(System.nanoTime() - t0 < nanos);
189 <            }});
190 <
191 <        t.start();
192 <        threadStarted.await();
193 <        Thread.sleep(SHORT_DELAY_MS);
194 <        t.interrupt();
195 <        joinWith(t);
160 >    public void testParkBeforeInterrupt_parkNanos() {
161 >        testParkBeforeInterrupt(ParkMethod.parkNanos);
162      }
163 <
164 <    /**
165 <     * parkNanos is released by subsequent interrupt
166 <     */
167 <    public void testParkNanosBeforeInterrupt() throws InterruptedException {
168 <        final CountDownLatch threadStarted = new CountDownLatch(1);
169 <        Thread t = new Thread(new CheckedRunnable() {
163 >    public void testParkBeforeInterrupt_parkUntil() {
164 >        testParkBeforeInterrupt(ParkMethod.parkUntil);
165 >    }
166 >    public void testParkBeforeInterrupt_parkBlocker() {
167 >        testParkBeforeInterrupt(ParkMethod.parkBlocker);
168 >    }
169 >    public void testParkBeforeInterrupt_parkNanosBlocker() {
170 >        testParkBeforeInterrupt(ParkMethod.parkNanosBlocker);
171 >    }
172 >    public void testParkBeforeInterrupt_parkUntilBlocker() {
173 >        testParkBeforeInterrupt(ParkMethod.parkUntilBlocker);
174 >    }
175 >    public void testParkBeforeInterrupt(final ParkMethod parkMethod) {
176 >        final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
177 >        Thread t = newStartedThread(new CheckedRunnable() {
178              public void realRun() {
179 <                long nanos = LONG_DELAY_MS * 1000L * 1000L;
180 <                long t0 = System.nanoTime();
181 <                threadStarted.countDown();
182 <                LockSupport.parkNanos(nanos);
183 <                assertTrue(System.nanoTime() - t0 < nanos);
179 >                pleaseInterrupt.countDown();
180 >                do {
181 >                    parkMethod.park();
182 >                    // park may return spuriously
183 >                } while (! Thread.currentThread().isInterrupted());
184              }});
185  
186 <        t.start();
187 <        threadStarted.await();
214 <        Thread.sleep(SHORT_DELAY_MS);
186 >        await(pleaseInterrupt);
187 >        assertThreadStaysAlive(t);
188          t.interrupt();
189 <        joinWith(t);
189 >        awaitTermination(t);
190      }
191  
192      /**
193       * park is released by preceding interrupt
194       */
195 <    public void testParkAfterInterrupt() throws Exception {
196 <        final CountDownLatch threadStarted = new CountDownLatch(1);
197 <        final AtomicBoolean unparked = new AtomicBoolean(false);
198 <        Thread t = new Thread(new CheckedRunnable() {
195 >    public void testParkAfterInterrupt_park() {
196 >        testParkAfterInterrupt(ParkMethod.park);
197 >    }
198 >    public void testParkAfterInterrupt_parkNanos() {
199 >        testParkAfterInterrupt(ParkMethod.parkNanos);
200 >    }
201 >    public void testParkAfterInterrupt_parkUntil() {
202 >        testParkAfterInterrupt(ParkMethod.parkUntil);
203 >    }
204 >    public void testParkAfterInterrupt_parkBlocker() {
205 >        testParkAfterInterrupt(ParkMethod.parkBlocker);
206 >    }
207 >    public void testParkAfterInterrupt_parkNanosBlocker() {
208 >        testParkAfterInterrupt(ParkMethod.parkNanosBlocker);
209 >    }
210 >    public void testParkAfterInterrupt_parkUntilBlocker() {
211 >        testParkAfterInterrupt(ParkMethod.parkUntilBlocker);
212 >    }
213 >    public void testParkAfterInterrupt(final ParkMethod parkMethod) {
214 >        final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
215 >        final AtomicBoolean pleasePark = new AtomicBoolean(false);
216 >        Thread t = newStartedThread(new CheckedRunnable() {
217              public void realRun() throws Exception {
218 <                threadStarted.countDown();
219 <                while (!unparked.get())
218 >                pleaseInterrupt.countDown();
219 >                while (!pleasePark.get())
220                      Thread.yield();
221                  assertTrue(Thread.currentThread().isInterrupted());
222 <                LockSupport.park();
222 >                parkMethod.park();
223                  assertTrue(Thread.currentThread().isInterrupted());
224              }});
225  
226 <        t.start();
236 <        threadStarted.await();
226 >        await(pleaseInterrupt);
227          t.interrupt();
228 <        unparked.set(true);
229 <        joinWith(t);
228 >        pleasePark.set(true);
229 >        awaitTermination(t);
230      }
231  
232      /**
233 <     * parkUntil is released by preceding interrupt
233 >     * timed park times out if not unparked
234       */
235 <    public void testParkUntilAfterInterrupt() throws Exception {
236 <        final CountDownLatch threadStarted = new CountDownLatch(1);
237 <        final AtomicBoolean unparked = new AtomicBoolean(false);
238 <        Thread t = new Thread(new CheckedRunnable() {
239 <            public void realRun() throws Exception {
240 <                threadStarted.countDown();
241 <                while (!unparked.get())
242 <                    Thread.yield();
243 <                long d = new Date().getTime() + LONG_DELAY_MS;
244 <                long nanos = LONG_DELAY_MS * 1000L * 1000L;
245 <                long t0 = System.nanoTime();
246 <                LockSupport.parkUntil(d);
247 <                assertTrue(System.nanoTime() - t0 < nanos);
235 >    public void testParkTimesOut_parkNanos() {
236 >        testParkTimesOut(ParkMethod.parkNanos);
237 >    }
238 >    public void testParkTimesOut_parkUntil() {
239 >        testParkTimesOut(ParkMethod.parkUntil);
240 >    }
241 >    public void testParkTimesOut_parkNanosBlocker() {
242 >        testParkTimesOut(ParkMethod.parkNanosBlocker);
243 >    }
244 >    public void testParkTimesOut_parkUntilBlocker() {
245 >        testParkTimesOut(ParkMethod.parkUntilBlocker);
246 >    }
247 >    public void testParkTimesOut(final ParkMethod parkMethod) {
248 >        Thread t = newStartedThread(new CheckedRunnable() {
249 >            public void realRun() {
250 >                for (;;) {
251 >                    long startTime = System.nanoTime();
252 >                    parkMethod.park(timeoutMillis());
253 >                    // park may return spuriously
254 >                    if (millisElapsedSince(startTime) >= timeoutMillis())
255 >                        return;
256 >                }
257              }});
258  
259 <        t.start();
261 <        threadStarted.await();
262 <        t.interrupt();
263 <        unparked.set(true);
264 <        joinWith(t);
259 >        awaitTermination(t);
260      }
261  
262      /**
263 <     * parkNanos is released by preceding interrupt
263 >     * getBlocker(null) throws NullPointerException
264       */
265 <    public void testParkNanosAfterInterrupt() throws Exception {
266 <        final CountDownLatch threadStarted = new CountDownLatch(1);
267 <        final AtomicBoolean unparked = new AtomicBoolean(false);
268 <        Thread t = new Thread(new CheckedRunnable() {
269 <            public void realRun() throws Exception {
275 <                threadStarted.countDown();
276 <                while (!unparked.get())
277 <                    Thread.yield();
278 <                long nanos = LONG_DELAY_MS * 1000L * 1000L;
279 <                long t0 = System.nanoTime();
280 <                LockSupport.parkNanos(nanos);
281 <                assertTrue(System.nanoTime() - t0 < nanos);
282 <            }});
283 <
284 <        t.start();
285 <        threadStarted.await();
286 <        t.interrupt();
287 <        unparked.set(true);
288 <        joinWith(t);
265 >    public void testGetBlockerNull() {
266 >        try {
267 >            LockSupport.getBlocker(null);
268 >            shouldThrow();
269 >        } catch (NullPointerException success) {}
270      }
271  
272      /**
273 <     * parkNanos times out if not unparked
273 >     * getBlocker returns the blocker object passed to park
274       */
275 <    public void testParkNanosTimesOut() throws InterruptedException {
276 <        Thread t = new Thread(new CheckedRunnable() {
275 >    public void testGetBlocker_parkBlocker() {
276 >        testGetBlocker(ParkMethod.parkBlocker);
277 >    }
278 >    public void testGetBlocker_parkNanosBlocker() {
279 >        testGetBlocker(ParkMethod.parkNanosBlocker);
280 >    }
281 >    public void testGetBlocker_parkUntilBlocker() {
282 >        testGetBlocker(ParkMethod.parkUntilBlocker);
283 >    }
284 >    public void testGetBlocker(final ParkMethod parkMethod) {
285 >        final CountDownLatch started = new CountDownLatch(1);
286 >        Thread t = newStartedThread(new CheckedRunnable() {
287              public void realRun() {
288 <                final long timeoutNanos = SHORT_DELAY_MS * 1000L * 1000L;
289 <                long t0 = System.nanoTime();
290 <                LockSupport.parkNanos(timeoutNanos);
291 <                assertTrue(System.nanoTime() - t0 >= timeoutNanos);
292 <            }});
293 <
294 <        t.start();
295 <        joinWith(t);
288 >                Thread t = Thread.currentThread();
289 >                started.countDown();
290 >                do {
291 >                    assertNull(LockSupport.getBlocker(t));
292 >                    parkMethod.park();
293 >                    assertNull(LockSupport.getBlocker(t));
294 >                    // park may return spuriously
295 >                } while (! Thread.currentThread().isInterrupted());
296 >            }});
297 >
298 >        long startTime = System.nanoTime();
299 >        await(started);
300 >        for (;;) {
301 >            Object x = LockSupport.getBlocker(t);
302 >            if (x == theBlocker()) { // success
303 >                t.interrupt();
304 >                awaitTermination(t);
305 >                assertNull(LockSupport.getBlocker(t));
306 >                return;
307 >            } else {
308 >                assertNull(x);  // ok
309 >                if (millisElapsedSince(startTime) > LONG_DELAY_MS)
310 >                    fail("timed out");
311 >                Thread.yield();
312 >            }
313 >        }
314      }
315  
307
316      /**
317 <     * parkUntil times out if not unparked
317 >     * timed park(0) returns immediately.
318 >     *
319 >     * Requires hotspot fix for:
320 >     * 6763959 java.util.concurrent.locks.LockSupport.parkUntil(0) blocks forever
321 >     * which is in jdk7-b118 and 6u25.
322       */
323 <    public void testParkUntilTimesOut() throws InterruptedException {
324 <        Thread t = new Thread(new CheckedRunnable() {
323 >    public void testPark0_parkNanos() {
324 >        testPark0(ParkMethod.parkNanos);
325 >    }
326 >    public void testPark0_parkUntil() {
327 >        testPark0(ParkMethod.parkUntil);
328 >    }
329 >    public void testPark0_parkNanosBlocker() {
330 >        testPark0(ParkMethod.parkNanosBlocker);
331 >    }
332 >    public void testPark0_parkUntilBlocker() {
333 >        testPark0(ParkMethod.parkUntilBlocker);
334 >    }
335 >    public void testPark0(final ParkMethod parkMethod) {
336 >        Thread t = newStartedThread(new CheckedRunnable() {
337              public void realRun() {
338 <                long d = new Date().getTime() + SHORT_DELAY_MS;
315 <                // beware of rounding
316 <                long timeoutNanos = (SHORT_DELAY_MS - 1) * 1000L * 1000L;
317 <                long t0 = System.nanoTime();
318 <                LockSupport.parkUntil(d);
319 <                assertTrue(System.nanoTime() - t0 >= timeoutNanos);
338 >                parkMethod.park(0L);
339              }});
340  
341 <        t.start();
323 <        joinWith(t);
341 >        awaitTermination(t);
342      }
343  
344      /**
345 <     * parkUntil(0) returns immediately
328 <     * Requires hotspot fix for:
329 <     * 6763959 java.util.concurrent.locks.LockSupport.parkUntil(0) blocks forever
345 >     * timed park(Long.MIN_VALUE) returns immediately.
346       */
347 <    public void XXXtestParkUntil0Returns() throws InterruptedException {
348 <        Thread t = new Thread(new CheckedRunnable() {
347 >    public void testParkNeg_parkNanos() {
348 >        testParkNeg(ParkMethod.parkNanos);
349 >    }
350 >    public void testParkNeg_parkUntil() {
351 >        testParkNeg(ParkMethod.parkUntil);
352 >    }
353 >    public void testParkNeg_parkNanosBlocker() {
354 >        testParkNeg(ParkMethod.parkNanosBlocker);
355 >    }
356 >    public void testParkNeg_parkUntilBlocker() {
357 >        testParkNeg(ParkMethod.parkUntilBlocker);
358 >    }
359 >    public void testParkNeg(final ParkMethod parkMethod) {
360 >        Thread t = newStartedThread(new CheckedRunnable() {
361              public void realRun() {
362 <                LockSupport.parkUntil(0L);
362 >                parkMethod.park(Long.MIN_VALUE);
363              }});
364  
365 <        t.start();
338 <        joinWith(t);
339 <    }
340 <
341 <    private void joinWith(Thread t) throws InterruptedException {
342 <        t.join(MEDIUM_DELAY_MS);
343 <        if (t.isAlive()) {
344 <            fail("Test timed out");
345 <            t.interrupt();
346 <        }
365 >        awaitTermination(t);
366      }
367   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines