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.23 by jsr166, Sat May 28 22:21:58 2011 UTC vs.
Revision 1.27 by jsr166, Fri May 12 18:12:52 2017 UTC

# Line 7 | Line 7
7   * Pat Fisher, Mike Judd.
8   */
9  
10 < import junit.framework.*;
10 > import static java.util.concurrent.TimeUnit.MILLISECONDS;
11 >
12   import java.util.concurrent.CountDownLatch;
13   import java.util.concurrent.atomic.AtomicBoolean;
14   import java.util.concurrent.locks.LockSupport;
15 < import static java.util.concurrent.TimeUnit.MILLISECONDS;
15 >
16 > import junit.framework.Test;
17 > import junit.framework.TestSuite;
18  
19   public class LockSupportTest extends JSR166TestCase {
20      public static void main(String[] args) {
21 <        junit.textui.TestRunner.run(suite());
21 >        main(suite(), args);
22      }
23  
24      public static Test suite() {
25          return new TestSuite(LockSupportTest.class);
26      }
27  
28 +    static {
29 +        // Reduce the risk of rare disastrous classloading in first call to
30 +        // LockSupport.park: https://bugs.openjdk.java.net/browse/JDK-8074773
31 +        Class<?> ensureLoaded = LockSupport.class;
32 +    }
33 +
34      /**
35       * Returns the blocker object used by tests in this file.
36       * Any old object will do; we'll return a convenient one.
# Line 247 | Line 256 | public class LockSupportTest extends JSR
256      public void testParkTimesOut(final ParkMethod parkMethod) {
257          Thread t = newStartedThread(new CheckedRunnable() {
258              public void realRun() {
259 <                for (;;) {
259 >                for (int tries = MAX_SPURIOUS_WAKEUPS; tries-->0; ) {
260                      long startTime = System.nanoTime();
261                      parkMethod.park(timeoutMillis());
262                      // park may return spuriously
263                      if (millisElapsedSince(startTime) >= timeoutMillis())
264                          return;
265                  }
266 +                fail("too many consecutive spurious wakeups?");
267              }});
268  
269          awaitTermination(t);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines