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

Comparing jsr166/src/test/tck/JSR166TestCase.java (file contents):
Revision 1.223 by jsr166, Sat May 13 19:13:09 2017 UTC vs.
Revision 1.224 by jsr166, Sat May 13 21:43:50 2017 UTC

# Line 1063 | Line 1063 | public class JSR166TestCase extends Test
1063      }
1064  
1065      /**
1066 +     * Checks that thread eventually enters the expected blocked thread state.
1067 +     */
1068 +    void assertThreadBlocks(Thread thread, Thread.State expected) {
1069 +        // always sleep at least 1 ms, avoiding transitional states
1070 +        // with high probability
1071 +        for (long retries = LONG_DELAY_MS; retries-->0; ) {
1072 +            try { delay(1); }
1073 +            catch (InterruptedException fail) {
1074 +                fail("Unexpected InterruptedException");
1075 +            }
1076 +            Thread.State s = thread.getState();
1077 +            if (s == expected)
1078 +                return;
1079 +            else if (s == Thread.State.TERMINATED)
1080 +                fail("Unexpected thread termination");
1081 +        }
1082 +        fail("timed out waiting for thread to enter thread state " + expected);
1083 +    }
1084 +
1085 +    /**
1086       * Checks that thread does not terminate within the default
1087       * millisecond delay of {@code timeoutMillis()}.
1088       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines