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.4 by dl, Mon Feb 19 00:46:06 2007 UTC vs.
Revision 1.5 by jsr166, Thu Oct 29 23:09:07 2009 UTC

# Line 7 | Line 7 | import java.util.concurrent.*;
7  
8   public class CancelledProducerConsumerLoops {
9      static final int CAPACITY =      100;
10 <    static final long TIMEOUT = 100;
10 >    static final long TIMEOUT = 100;
11  
12      static final ExecutorService pool = Executors.newCachedThreadPool();
13      static boolean print = false;
# Line 16 | Line 16 | public class CancelledProducerConsumerLo
16          int maxPairs = 8;
17          int iters = 1000000;
18  
19 <        if (args.length > 0)
19 >        if (args.length > 0)
20              maxPairs = Integer.parseInt(args[0]);
21  
22          print = true;
23 <        
23 >
24          for (int i = 1; i <= maxPairs; i += (i+1) >>> 1) {
25              System.out.println("Pairs:" + i);
26              try {
# Line 39 | Line 39 | public class CancelledProducerConsumerLo
39          CyclicBarrier barrier = new CyclicBarrier(npairs * 2 + 1, timer);
40          Future[] prods = new Future[npairs];
41          Future[] cons = new Future[npairs];
42 <        
42 >
43          for (int i = 0; i < npairs; ++i) {
44              prods[i] = pool.submit(new Producer(q, barrier, iters));
45              cons[i] = pool.submit(new Consumer(q, barrier, iters));
# Line 103 | Line 103 | public class CancelledProducerConsumerLo
103          oneRun(new PriorityBlockingQueue<Integer>(ITERS / 2 * pairs), pairs, iters / 4);
104          */
105      }
106 <    
106 >
107      static abstract class Stage implements Callable {
108          final BlockingQueue<Integer> queue;
109          final CyclicBarrier barrier;
110          final int iters;
111          Stage (BlockingQueue<Integer> q, CyclicBarrier b, int iters) {
112 <            queue = q;
112 >            queue = q;
113              barrier = b;
114              this.iters = iters;
115          }
# Line 135 | Line 135 | public class CancelledProducerConsumerLo
135      }
136  
137      static class Consumer extends Stage {
138 <        Consumer(BlockingQueue<Integer> q, CyclicBarrier b, int iters) {
138 >        Consumer(BlockingQueue<Integer> q, CyclicBarrier b, int iters) {
139              super(q, b, iters);
140          }
141  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines