jdk/test/java/util/concurrent/Exchanger/ExchangeLoops.java
changeset 34347 4a17f9e90a0f
parent 32991 b27c76b82713
child 36233 f85ed703cf7e
equal deleted inserted replaced
34346:09f5f3df8fa8 34347:4a17f9e90a0f
    36  * @bug 4486658
    36  * @bug 4486658
    37  * @run main/timeout=720 ExchangeLoops
    37  * @run main/timeout=720 ExchangeLoops
    38  * @summary checks to make sure a pipeline of exchangers passes data.
    38  * @summary checks to make sure a pipeline of exchangers passes data.
    39  */
    39  */
    40 
    40 
    41 import java.util.concurrent.*;
    41 import static java.util.concurrent.TimeUnit.SECONDS;
       
    42 
       
    43 import java.util.concurrent.CyclicBarrier;
       
    44 import java.util.concurrent.Exchanger;
       
    45 import java.util.concurrent.ExecutorService;
       
    46 import java.util.concurrent.Executors;
    42 
    47 
    43 public class ExchangeLoops {
    48 public class ExchangeLoops {
    44     static final ExecutorService pool = Executors.newCachedThreadPool();
    49     static final ExecutorService pool = Executors.newCachedThreadPool();
    45     static boolean print = false;
    50     static boolean print = false;
    46 
    51 
    64         for (int i = 2; i <= maxStages; i += (i+1) >>> 1) {
    69         for (int i = 2; i <= maxStages; i += (i+1) >>> 1) {
    65             System.out.print("Threads: " + i + "\t: ");
    70             System.out.print("Threads: " + i + "\t: ");
    66             oneRun(i, iters);
    71             oneRun(i, iters);
    67         }
    72         }
    68         pool.shutdown();
    73         pool.shutdown();
    69         if (! pool.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS))
    74         if (! pool.awaitTermination(60L, SECONDS))
    70             throw new Error();
    75             throw new Error();
    71    }
    76    }
    72 
    77 
    73     static class Stage implements Runnable {
    78     static class Stage implements Runnable {
    74         final int iters;
    79         final int iters;