Print this page


Split Close
Expand all
Collapse all
          --- old/test/java/util/concurrent/Exchanger/ExchangeLoops.java
          +++ new/test/java/util/concurrent/Exchanger/ExchangeLoops.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 ExchangeLoops.java
       37 + * @compile -source 1.5 ExchangeLoops.java
  38   38   * @run main/timeout=720 ExchangeLoops
  39   39   * @summary checks to make sure a pipeline of exchangers passes data.
  40   40   */
  41   41  
  42   42  import java.util.concurrent.*;
  43   43  
  44   44  public class ExchangeLoops {
  45   45      static final ExecutorService pool = Executors.newCachedThreadPool();
  46   46      static boolean print = false;
  47   47  
↓ open down ↓ 23 lines elided ↑ open up ↑
  71   71          if (! pool.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS))
  72   72              throw new Error();
  73   73     }
  74   74  
  75   75      static class Stage implements Runnable {
  76   76          final int iters;
  77   77          final Exchanger<Int> left;
  78   78          final Exchanger<Int> right;
  79   79          final CyclicBarrier barrier;
  80   80          volatile int result;
  81      -        Stage (Exchanger<Int> left,
  82      -               Exchanger<Int> right,
  83      -               CyclicBarrier b, int iters) {
       81 +        Stage(Exchanger<Int> left,
       82 +              Exchanger<Int> right,
       83 +              CyclicBarrier b, int iters) {
  84   84              this.left = left;
  85   85              this.right = right;
  86   86              barrier = b;
  87   87              this.iters = iters;
  88   88          }
  89   89  
  90   90          public void run() {
  91   91              try {
  92   92                  barrier.await();
  93   93                  Int item = new Int(hashCode());
↓ open down ↓ 45 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX