Print this page


Split Close
Expand all
Collapse all
          --- old/test/java/util/concurrent/FutureTask/CancelledFutureLoops.java
          +++ new/test/java/util/concurrent/FutureTask/CancelledFutureLoops.java
↓ open down ↓ 26 lines elided ↑ open up ↑
  27   27   * file:
  28   28   *
  29   29   * Written by Doug Lea with assistance from members of JCP JSR-166
  30   30   * Expert Group and released to the public domain, as explained at
  31   31   * http://creativecommons.org/licenses/publicdomain
  32   32   */
  33   33  
  34   34  /*
  35   35   * @test
  36   36   * @bug 4486658
  37      - * @compile CancelledFutureLoops.java
       37 + * @compile -source 1.5 CancelledFutureLoops.java
  38   38   * @run main/timeout=2000 CancelledFutureLoops
  39   39   * @summary Checks for responsiveness of futures to cancellation.
  40   40   * Runs under the assumption that ITERS computations require more than
  41   41   * TIMEOUT msecs to complete.
  42   42   */
  43   43  
  44   44  import java.util.concurrent.*;
  45   45  import java.util.concurrent.locks.*;
  46   46  import java.util.*;
  47   47  
↓ open down ↓ 9 lines elided ↑ open up ↑
  57   57          if (args.length > 0)
  58   58              maxThreads = Integer.parseInt(args[0]);
  59   59  
  60   60          print = true;
  61   61  
  62   62          for (int i = 2; i <= maxThreads; i += (i+1) >>> 1) {
  63   63              System.out.print("Threads: " + i);
  64   64              try {
  65   65                  new FutureLoop(i).test();
  66   66              }
  67      -            catch(BrokenBarrierException bb) {
       67 +            catch (BrokenBarrierException bb) {
  68   68                  // OK; ignore
  69   69              }
  70      -            catch(ExecutionException ee) {
       70 +            catch (ExecutionException ee) {
  71   71                  // OK; ignore
  72   72              }
  73   73              Thread.sleep(TIMEOUT);
  74   74          }
  75   75          pool.shutdown();
  76   76          if (! pool.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS))
  77   77              throw new Error();
  78   78      }
  79   79  
  80   80      static final class FutureLoop implements Callable {
↓ open down ↓ 65 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX