test/java/util/concurrent/CopyOnWriteArraySet/RacingCows.java

Print this page




 108             catch (Throwable t) { unexpected(t); }
 109         }
 110         t2.join();
 111         t3.join();
 112     }
 113 
 114     //--------------------- Infrastructure ---------------------------
 115     static volatile int passed = 0, failed = 0;
 116     static void pass() {passed++;}
 117     static void fail() {failed++; Thread.dumpStack();}
 118     static void fail(String msg) {System.out.println(msg); fail();}
 119     static void unexpected(Throwable t) {failed++; t.printStackTrace();}
 120     static void check(boolean cond) {if (cond) pass(); else fail();}
 121     static void equal(Object x, Object y) {
 122         if (x == null ? y == null : x.equals(y)) pass();
 123         else fail(x + " not equal to " + y);}
 124     public static void main(String[] args) throws Throwable {
 125         try {realMain(args);} catch (Throwable t) {unexpected(t);}
 126         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
 127         if (failed > 0) throw new AssertionError("Some tests failed");}
 128     private static abstract class CheckedThread extends Thread {
 129         public abstract void realRun() throws Throwable;
 130         public void run() {
 131             try { realRun(); } catch (Throwable t) { unexpected(t); }}}
 132 }


 108             catch (Throwable t) { unexpected(t); }
 109         }
 110         t2.join();
 111         t3.join();
 112     }
 113 
 114     //--------------------- Infrastructure ---------------------------
 115     static volatile int passed = 0, failed = 0;
 116     static void pass() {passed++;}
 117     static void fail() {failed++; Thread.dumpStack();}
 118     static void fail(String msg) {System.out.println(msg); fail();}
 119     static void unexpected(Throwable t) {failed++; t.printStackTrace();}
 120     static void check(boolean cond) {if (cond) pass(); else fail();}
 121     static void equal(Object x, Object y) {
 122         if (x == null ? y == null : x.equals(y)) pass();
 123         else fail(x + " not equal to " + y);}
 124     public static void main(String[] args) throws Throwable {
 125         try {realMain(args);} catch (Throwable t) {unexpected(t);}
 126         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
 127         if (failed > 0) throw new AssertionError("Some tests failed");}
 128     private abstract static class CheckedThread extends Thread {
 129         public abstract void realRun() throws Throwable;
 130         public void run() {
 131             try { realRun(); } catch (Throwable t) { unexpected(t); }}}
 132 }