--- jsr166/src/test/loops/SingleProducerMultipleConsumerLoops.java 2009/10/23 19:57:07 1.3 +++ jsr166/src/test/loops/SingleProducerMultipleConsumerLoops.java 2009/10/29 23:09:08 1.4 @@ -22,14 +22,14 @@ public class SingleProducerMultipleConsu static final int POOL_MASK = POOL_SIZE-1; static final Integer[] intPool = new Integer[POOL_SIZE]; static { - for (int i = 0; i < POOL_SIZE; ++i) + for (int i = 0; i < POOL_SIZE; ++i) intPool[i] = Integer.valueOf(i); } public static void main(String[] args) throws Exception { int maxn = 12; - if (args.length > 0) + if (args.length > 0) maxn = Integer.parseInt(args[0]); print = false; @@ -43,11 +43,11 @@ public class SingleProducerMultipleConsu if (i == k) { k = i << 1; i = i + (i >>> 1); - } - else + } + else i = k; } - + pool.shutdown(); } @@ -56,14 +56,14 @@ public class SingleProducerMultipleConsu System.out.print("Warmup "); int it = 2000; for (int j = 5; j > 0; --j) { - oneTest(j, it); + oneTest(j, it); System.out.print("."); it += 1000; } System.gc(); it = 20000; for (int j = 5; j > 0; --j) { - oneTest(j, it); + oneTest(j, it); System.out.print("."); it += 10000; } @@ -93,7 +93,7 @@ public class SingleProducerMultipleConsu if (print) System.out.print("LinkedBlockingDeque "); oneRun(new LinkedBlockingDeque(), n, iters); - + Thread.sleep(100); // System.gc(); if (print) System.out.print("ArrayBlockingQueue "); @@ -103,7 +103,7 @@ public class SingleProducerMultipleConsu if (print) System.out.print("SynchronousQueue "); oneRun(new SynchronousQueue(), n, iters); - + Thread.sleep(100); // System.gc(); if (print) System.out.print("SynchronousQueue(fair) "); @@ -118,7 +118,7 @@ public class SingleProducerMultipleConsu if (print) System.out.print("LinkedTransferQueue(half)"); oneRun(new HalfSyncLTQ(), n, iters); - + Thread.sleep(100); // System.gc(); if (print) System.out.print("PriorityBlockingQueue "); @@ -130,14 +130,14 @@ public class SingleProducerMultipleConsu oneRun(new ArrayBlockingQueue(POOL_SIZE, true), n, fairIters); } - + static abstract class Stage implements Runnable { final int iters; final BlockingQueue queue; final CyclicBarrier barrier; volatile int result; Stage (BlockingQueue q, CyclicBarrier b, int iters) { - queue = q; + queue = q; barrier = b; this.iters = iters; } @@ -160,15 +160,15 @@ public class SingleProducerMultipleConsu barrier.await(); result = 432; } - catch (Exception ie) { - ie.printStackTrace(); - return; + catch (Exception ie) { + ie.printStackTrace(); + return; } } } static class Consumer extends Stage { - Consumer(BlockingQueue q, CyclicBarrier b, int iters) { + Consumer(BlockingQueue q, CyclicBarrier b, int iters) { super(q, b, iters); } @@ -186,9 +186,9 @@ public class SingleProducerMultipleConsu result = s; if (s == 0) System.out.print(" "); } - catch (Exception ie) { - ie.printStackTrace(); - return; + catch (Exception ie) { + ie.printStackTrace(); + return; } } @@ -211,7 +211,7 @@ public class SingleProducerMultipleConsu static final class LTQasSQ extends LinkedTransferQueue { LTQasSQ() { super(); } public void put(T x) { - try { super.transfer(x); + try { super.transfer(x); } catch (InterruptedException ex) { throw new Error(); } } } @@ -223,9 +223,9 @@ public class SingleProducerMultipleConsu if ((++calls & 1) == 0) super.put(x); else { - try { super.transfer(x); - } catch (InterruptedException ex) { - throw new Error(); + try { super.transfer(x); + } catch (InterruptedException ex) { + throw new Error(); } } }