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

Comparing jsr166/src/test/loops/CachedThreadPoolLoops.java (file contents):
Revision 1.4 by dl, Fri Oct 23 19:57:06 2009 UTC vs.
Revision 1.5 by jsr166, Thu Oct 29 23:09:07 2009 UTC

# Line 15 | Line 15 | public class CachedThreadPoolLoops {
15  
16      public static void main(String[] args) throws Exception {
17          int maxThreads = NCPUS * 3 / 2; // 100;
18 <        if (args.length > 0)
18 >        if (args.length > 0)
19              maxThreads = Integer.parseInt(args[0]);
20  
21          System.out.print("Warmup:");
# Line 28 | Line 28 | public class CachedThreadPoolLoops {
28                  if (i == k) {
29                      k = i << 1;
30                      i = i + (i >>> 1);
31 <                }
32 <                else
31 >                }
32 >                else
33                      i = k;
34              }
35          }
# Line 43 | Line 43 | public class CachedThreadPoolLoops {
43              if (i == k) {
44                  k = i << 1;
45                  i = i + (i >>> 1);
46 <            }
47 <            else
46 >            }
47 >            else
48                  i = k;
49          }
50     }
# Line 83 | Line 83 | public class CachedThreadPoolLoops {
83      static final class Task implements Runnable {
84          final ThreadPoolExecutor pool;
85          final CountDownLatch done;
86 <        Task(ThreadPoolExecutor p, CountDownLatch d) {
87 <            pool = p;
86 >        Task(ThreadPoolExecutor p, CountDownLatch d) {
87 >            pool = p;
88              done = d;
89          }
90          public void run() {
# Line 92 | Line 92 | public class CachedThreadPoolLoops {
92              remaining.incrementAndGet();
93              int n;
94              while (!Thread.interrupted() &&
95 <                   (n = remaining.get()) > 0 &&
95 >                   (n = remaining.get()) > 0 &&
96                     done.getCount() > 0) {
97                  if (remaining.compareAndSet(n, n-1)) {
98                      try {
# Line 107 | Line 107 | public class CachedThreadPoolLoops {
107              }
108          }
109      }
110 <    
110 >
111      static void oneRun(BlockingQueue<Runnable> q, int nThreads, int iters, boolean print) throws Exception {
112 <      
113 <        ThreadPoolExecutor pool =
112 >
113 >        ThreadPoolExecutor pool =
114              new ThreadPoolExecutor(nThreads+1, Integer.MAX_VALUE,
115                                     1L, TimeUnit.SECONDS, q);
116  
# Line 134 | Line 134 | public class CachedThreadPoolLoops {
134      static final class LTQasSQ<T> extends LinkedTransferQueue<T> {
135          LTQasSQ() { super(); }
136          public void put(T x) {
137 <            try { super.transfer(x);
137 >            try { super.transfer(x);
138              } catch (InterruptedException ex) { throw new Error(); }
139          }
140      }
# Line 146 | Line 146 | public class CachedThreadPoolLoops {
146              if ((++calls & 1) == 0)
147                  super.put(x);
148              else {
149 <                try { super.transfer(x);
150 <                } catch (InterruptedException ex) {
151 <                    throw new Error();
149 >                try { super.transfer(x);
150 >                } catch (InterruptedException ex) {
151 >                    throw new Error();
152                  }
153              }
154          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines