test/java/util/concurrent/CyclicBarrier/Basic.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -38,14 +38,12 @@
private static void checkBroken(final CyclicBarrier barrier) {
check(barrier.isBroken());
equal(barrier.getNumberWaiting(), 0);
THROWS(BrokenBarrierException.class,
- new Fun() { public void f() throws Throwable {
- barrier.await(); }},
- new Fun() { public void f() throws Throwable {
- barrier.await(100, MILLISECONDS); }});
+ () -> barrier.await(),
+ () -> barrier.await(100, MILLISECONDS));
}
private static void reset(CyclicBarrier barrier) {
barrier.reset();
check(! barrier.isBroken());
@@ -415,11 +413,11 @@
else fail(x + " not equal to " + y);}
public static void main(String[] args) throws Throwable {
try {realMain(args);} catch (Throwable t) {unexpected(t);}
System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
if (failed > 0) throw new AssertionError("Some tests failed");}
- abstract static class Fun { abstract void f() throws Throwable; }
+ @FunctionalInterface interface Fun {void f() throws Throwable;}
private static void THROWS(Class<? extends Throwable> k, Fun... fs) {
for (Fun f : fs)
try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
catch (Throwable t) {
if (k.isAssignableFrom(t.getClass())) pass();