8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6253848 6366811
27 * @summary Basic tests for CyclicBarrier
28 * @library /lib/testlibrary/
29 * @author Martin Buchholz, David Holmes
30 */
31
32 import static java.util.concurrent.TimeUnit.MILLISECONDS;
33
34 import java.util.ArrayList;
35 import java.util.Iterator;
36 import java.util.List;
37 import java.util.concurrent.BrokenBarrierException;
38 import java.util.concurrent.CountDownLatch;
39 import java.util.concurrent.CyclicBarrier;
40 import java.util.concurrent.TimeoutException;
41 import java.util.concurrent.atomic.AtomicInteger;
42 import jdk.testlibrary.Utils;
43
44 public class Basic {
45 static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
46
47 private static void checkBroken(final CyclicBarrier barrier) {
48 check(barrier.isBroken());
49 equal(barrier.getNumberWaiting(), 0);
50
51 THROWS(BrokenBarrierException.class,
52 () -> barrier.await(),
53 () -> barrier.await(100, MILLISECONDS));
54 }
55
56 private static void reset(CyclicBarrier barrier) {
57 barrier.reset();
58 check(! barrier.isBroken());
59 equal(barrier.getNumberWaiting(), 0);
60 }
61
62 private static void checkResult(Awaiter a, Class<? extends Throwable> c) {
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6253848 6366811
27 * @summary Basic tests for CyclicBarrier
28 * @library /test/lib
29 * @author Martin Buchholz, David Holmes
30 */
31
32 import static java.util.concurrent.TimeUnit.MILLISECONDS;
33
34 import java.util.ArrayList;
35 import java.util.Iterator;
36 import java.util.List;
37 import java.util.concurrent.BrokenBarrierException;
38 import java.util.concurrent.CountDownLatch;
39 import java.util.concurrent.CyclicBarrier;
40 import java.util.concurrent.TimeoutException;
41 import java.util.concurrent.atomic.AtomicInteger;
42 import jdk.test.lib.Utils;
43
44 public class Basic {
45 static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
46
47 private static void checkBroken(final CyclicBarrier barrier) {
48 check(barrier.isBroken());
49 equal(barrier.getNumberWaiting(), 0);
50
51 THROWS(BrokenBarrierException.class,
52 () -> barrier.await(),
53 () -> barrier.await(100, MILLISECONDS));
54 }
55
56 private static void reset(CyclicBarrier barrier) {
57 barrier.reset();
58 check(! barrier.isBroken());
59 equal(barrier.getNumberWaiting(), 0);
60 }
61
62 private static void checkResult(Awaiter a, Class<? extends Throwable> c) {
|