Print this page


Split Close
Expand all
Collapse all
          --- old/test/java/util/concurrent/CyclicBarrier/Basic.java
          +++ new/test/java/util/concurrent/CyclicBarrier/Basic.java
↓ open down ↓ 75 lines elided ↑ open up ↑
  76   76          catch (Throwable t) {
  77   77              unexpected(t);
  78   78              reset(atTheStartingGate);
  79   79              throw new Error(t);
  80   80          }
  81   81      }
  82   82  
  83   83      //----------------------------------------------------------------
  84   84      // Convenience methods for creating threads that call CyclicBarrier.await
  85   85      //----------------------------------------------------------------
  86      -    private static abstract class Awaiter extends Thread {
       86 +    private abstract static class Awaiter extends Thread {
  87   87          static AtomicInteger count = new AtomicInteger(1);
  88   88  
  89   89          {
  90   90              this.setName("Awaiter:"+count.getAndIncrement());
  91   91              this.setDaemon(true);
  92   92          }
  93   93  
  94   94          private volatile Throwable result = null;
  95   95          protected void result(Throwable result) { this.result = result; }
  96   96          public Throwable result() { return this.result; }
↓ open down ↓ 313 lines elided ↑ open up ↑
 410  410      static void fail(String msg) {System.out.println(msg); fail();}
 411  411      static void unexpected(Throwable t) {failed++; t.printStackTrace();}
 412  412      static void check(boolean cond) {if (cond) pass(); else fail();}
 413  413      static void equal(Object x, Object y) {
 414  414          if (x == null ? y == null : x.equals(y)) pass();
 415  415          else fail(x + " not equal to " + y);}
 416  416      public static void main(String[] args) throws Throwable {
 417  417          try {realMain(args);} catch (Throwable t) {unexpected(t);}
 418  418          System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
 419  419          if (failed > 0) throw new AssertionError("Some tests failed");}
 420      -    static abstract class Fun { abstract void f() throws Throwable; }
      420 +    abstract static class Fun { abstract void f() throws Throwable; }
 421  421      private static void THROWS(Class<? extends Throwable> k, Fun... fs) {
 422  422          for (Fun f : fs)
 423  423              try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
 424  424              catch (Throwable t) {
 425  425                  if (k.isAssignableFrom(t.getClass())) pass();
 426  426                  else unexpected(t);}}
 427      -    private static abstract class CheckedThread extends Thread {
      427 +    private abstract static class CheckedThread extends Thread {
 428  428          abstract void realRun() throws Throwable;
 429  429          public void run() {
 430  430              try {realRun();} catch (Throwable t) {unexpected(t);}}}
 431  431  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX