ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/loops/CancelledProducerConsumerLoops.java
(Generate patch)

Comparing jsr166/src/test/loops/CancelledProducerConsumerLoops.java (file contents):
Revision 1.6 by dl, Fri Oct 30 14:15:04 2009 UTC vs.
Revision 1.14 by jsr166, Thu Jan 15 18:34:18 2015 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6   import java.util.concurrent.*;
7  
# Line 26 | Line 26 | public class CancelledProducerConsumerLo
26              try {
27                  oneTest(i, iters);
28              }
29 <            catch(BrokenBarrierException bb) {
29 >            catch (BrokenBarrierException bb) {
30                  // OK, ignore
31              }
32              Thread.sleep(100);
33          }
34          pool.shutdown();
35 <   }
35 >    }
36  
37      static void oneRun(BlockingQueue<Integer> q, int npairs, int iters) throws Exception {
38          LoopHelpers.BarrierTimer timer = new LoopHelpers.BarrierTimer();
39          CyclicBarrier barrier = new CyclicBarrier(npairs * 2 + 1, timer);
40 <        Future[] prods = new Future[npairs];
41 <        Future[] cons = new Future[npairs];
40 >        Future<?>[] prods = new Future<?>[npairs];
41 >        Future<?>[] cons = new Future<?>[npairs];
42  
43          for (int i = 0; i < npairs; ++i) {
44              prods[i] = pool.submit(new Producer(q, barrier, iters));
# Line 72 | Line 72 | public class CancelledProducerConsumerLo
72          long endTime = System.nanoTime();
73          long time = endTime - timer.startTime;
74          if (print) {
75 <            double secs = (double)(time) / 1000000000.0;
75 >            double secs = (double) time / 1000000000.0;
76              System.out.println("\t " + secs + "s run time");
77          }
78      }
# Line 95 | Line 95 | public class CancelledProducerConsumerLo
95              System.out.print("SynchronousQueue        ");
96          oneRun(new SynchronousQueue<Integer>(), pairs, iters / 8);
97  
98
98          if (print)
99              System.out.print("SynchronousQueue(fair)  ");
100          oneRun(new SynchronousQueue<Integer>(true), pairs, iters / 8);
# Line 107 | Line 106 | public class CancelledProducerConsumerLo
106          */
107      }
108  
109 <    static abstract class Stage implements Callable {
109 >    abstract static class Stage implements Callable {
110          final BlockingQueue<Integer> queue;
111          final CyclicBarrier barrier;
112          final int iters;
113 <        Stage (BlockingQueue<Integer> q, CyclicBarrier b, int iters) {
113 >        Stage(BlockingQueue<Integer> q, CyclicBarrier b, int iters) {
114              queue = q;
115              barrier = b;
116              this.iters = iters;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines