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

Comparing jsr166/src/test/loops/CheckedLockLoops.java (file contents):
Revision 1.3 by jsr166, Sat Aug 1 22:12:59 2009 UTC vs.
Revision 1.4 by jsr166, Thu Oct 29 23:09:07 2009 UTC

# Line 21 | Line 21 | public final class CheckedLockLoops {
21      public static void main(String[] args) throws Exception {
22          int maxThreads = 100;
23          int iters = 2000000;
24 <        if (args.length > 0)
24 >        if (args.length > 0)
25              maxThreads = Integer.parseInt(args[0]);
26          rng.setSeed(3122688L);
27          warmup(iters);
# Line 38 | Line 38 | public final class CheckedLockLoops {
38              if (i == k) {
39                  k = i << 1;
40                  i = i + (i >>> 1);
41 <            }
42 <            else
41 >            }
42 >            else
43                  i = k;
44          }
45 <    }    
45 >    }
46  
47      static void warmup(int iters) throws Exception {
48          print = false;
# Line 59 | Line 59 | public final class CheckedLockLoops {
59              System.out.print("NoLock (1 thread)     ");
60          new NoLockLoop().test(v, 1, iters * nthreads);
61          Thread.sleep(10);
62 <
62 >
63          if (print)
64              System.out.print("ReentrantLock         ");
65          new ReentrantLockLoop().test(v, nthreads, iters);
# Line 91 | Line 91 | public final class CheckedLockLoops {
91              System.out.print("Semaphore             ");
92          new SemaphoreLoop().test(v, nthreads, iters);
93          Thread.sleep(10);
94 <        
94 >
95          if (print)
96              System.out.print("FairSemaphore         ");
97          new FairSemaphoreLoop().test(v, nthreads, fairIters);
# Line 106 | Line 106 | public final class CheckedLockLoops {
106              System.out.print("FairRWriteLock         ");
107          new FairReentrantWriteLockLoop().test(v, nthreads, fairIters);
108          Thread.sleep(10);
109 <        
109 >
110          if (print)
111              System.out.print("ReentrantReadWriteLock");
112          new ReentrantReadWriteLockLoop().test(v, nthreads, iters);
113          Thread.sleep(10);
114 <        
114 >
115          if (print)
116              System.out.print("FairRReadWriteLock     ");
117          new FairReentrantReadWriteLockLoop().test(v, nthreads, fairIters);
# Line 135 | Line 135 | public final class CheckedLockLoops {
135  
136          final int getValue() {
137              int v = value;
138 <            if (checkValue != ~(v ^ 0xAAAAAAAA))
138 >            if (checkValue != ~(v ^ 0xAAAAAAAA))
139                  ++failures;
140              return v;
141          }
# Line 144 | Line 144 | public final class CheckedLockLoops {
144              setValue(initialValue);
145              this.iters = iters;
146              barrier = new CyclicBarrier(nthreads+1, timer);
147 <            for (int i = 0; i < nthreads; ++i)
147 >            for (int i = 0; i < nthreads; ++i)
148                  pool.execute(this);
149              barrier.await();
150              barrier.await();
# Line 164 | Line 164 | public final class CheckedLockLoops {
164          abstract int loop(int n);
165          public final void run() {
166              try {
167 <                barrier.await();
167 >                barrier.await();
168                  result += loop(iters);
169                  barrier.await();
170              }
171 <            catch (Exception ie) {
172 <                return;
171 >            catch (Exception ie) {
172 >                return;
173              }
174          }
175  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines