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.28 by jsr166, Fri May 12 18:23:11 2017 UTC vs.
Revision 1.30 by jsr166, Fri May 12 18:57:11 2017 UTC

# Line 186 | Line 186 | public class LockSupportTest extends JSR
186          Thread t = newStartedThread(new CheckedRunnable() {
187              public void realRun() {
188                  pleaseInterrupt.countDown();
189 <                do {
189 >                for (int tries = MAX_SPURIOUS_WAKEUPS; tries-->0; ) {
190                      parkMethod.park();
191 <                    // park may return spuriously
192 <                } while (! Thread.interrupted());
191 >                    if (Thread.interrupted())
192 >                        return;
193 >                }
194 >                fail("too many consecutive spurious wakeups?");
195              }});
196  
197          await(pleaseInterrupt);
# Line 221 | Line 223 | public class LockSupportTest extends JSR
223      }
224      public void testParkAfterInterrupt(final ParkMethod parkMethod) {
225          final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
224        final AtomicBoolean pleasePark = new AtomicBoolean(false);
226          Thread t = newStartedThread(new CheckedRunnable() {
227              public void realRun() throws Exception {
228                  pleaseInterrupt.countDown();
229 <                while (!pleasePark.get())
229 >                while (!Thread.currentThread().isInterrupted())
230                      Thread.yield();
230                assertTrue(Thread.currentThread().isInterrupted());
231                  parkMethod.park();
232 <                assertTrue(Thread.currentThread().isInterrupted());
232 >                assertTrue(Thread.interrupted());
233              }});
234  
235          await(pleaseInterrupt);
236          t.interrupt();
237        pleasePark.set(true);
237          awaitTermination(t);
238      }
239  
# Line 259 | Line 258 | public class LockSupportTest extends JSR
258                  for (int tries = MAX_SPURIOUS_WAKEUPS; tries-->0; ) {
259                      long startTime = System.nanoTime();
260                      parkMethod.park(timeoutMillis());
262                    // park may return spuriously
261                      if (millisElapsedSince(startTime) >= timeoutMillis())
262                          return;
263                  }
# Line 297 | Line 295 | public class LockSupportTest extends JSR
295              public void realRun() {
296                  Thread t = Thread.currentThread();
297                  started.countDown();
298 <                do {
298 >                for (int tries = MAX_SPURIOUS_WAKEUPS; tries-->0; ) {
299                      assertNull(LockSupport.getBlocker(t));
300                      parkMethod.park();
301                      assertNull(LockSupport.getBlocker(t));
302 <                    // park may return spuriously
303 <                } while (! Thread.interrupted());
302 >                    if (Thread.interrupted())
303 >                        return;
304 >                }
305 >                fail("too many consecutive spurious wakeups?");
306              }});
307  
308          long startTime = System.nanoTime();
# Line 318 | Line 318 | public class LockSupportTest extends JSR
318                  assertNull(x);  // ok
319                  if (millisElapsedSince(startTime) > LONG_DELAY_MS)
320                      fail("timed out");
321 +                if (t.getState() == Thread.State.TERMINATED)
322 +                    break;
323                  Thread.yield();
324              }
325          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines