Print this page


Split Close
Expand all
Collapse all
          --- old/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java
          +++ new/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java
↓ open down ↓ 28 lines elided ↑ open up ↑
  29   29   * @author Martin Buchholz
  30   30   */
  31   31  
  32   32  import java.security.*;
  33   33  import java.util.*;
  34   34  import java.util.concurrent.*;
  35   35  import java.util.concurrent.atomic.*;
  36   36  import static java.util.concurrent.TimeUnit.*;
  37   37  
  38   38  public class ConfigChanges {
  39      -    final static ThreadGroup tg = new ThreadGroup("pool");
       39 +    static final ThreadGroup tg = new ThreadGroup("pool");
  40   40  
  41      -    final static Random rnd = new Random();
       41 +    static final Random rnd = new Random();
  42   42  
  43   43      static void report(ThreadPoolExecutor tpe) {
  44   44          try {
  45   45              System.out.printf(
  46   46                  "active=%d submitted=%d completed=%d queued=%d sizes=%d/%d/%d%n",
  47   47                  tg.activeCount(),
  48   48                  tpe.getTaskCount(),
  49   49                  tpe.getCompletedTaskCount(),
  50   50                  tpe.getQueue().size(),
  51   51                  tpe.getPoolSize(),
↓ open down ↓ 182 lines elided ↑ open up ↑
 234  234      static void fail(String msg) {System.out.println(msg); fail();}
 235  235      static void unexpected(Throwable t) {failed++; t.printStackTrace();}
 236  236      static void check(boolean cond) {if (cond) pass(); else fail();}
 237  237      static void equal(Object x, Object y) {
 238  238          if (x == null ? y == null : x.equals(y)) pass();
 239  239          else fail(x + " not equal to " + y);}
 240  240      public static void main(String[] args) throws Throwable {
 241  241          try {realMain(args);} catch (Throwable t) {unexpected(t);}
 242  242          System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
 243  243          if (failed > 0) throw new AssertionError("Some tests failed");}
 244      -    private static abstract class Fun {abstract void f() throws Throwable;}
      244 +    private abstract static class Fun {abstract void f() throws Throwable;}
 245  245      static void THROWS(Class<? extends Throwable> k, Fun... fs) {
 246  246          for (Fun f : fs)
 247  247              try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
 248  248              catch (Throwable t) {
 249  249                  if (k.isAssignableFrom(t.getClass())) pass();
 250  250                  else unexpected(t);}}
 251  251  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX