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

Comparing jsr166/src/test/loops/LockOncePerThreadLoops.java (file contents):
Revision 1.1 by dl, Mon May 2 19:19:38 2005 UTC vs.
Revision 1.6 by jsr166, Wed Dec 31 17:00:58 2014 UTC

# Line 1 | Line 1
1   /*
2 * @test
3 * @summary Checks for missed signals by locking and unlocking each of an array of locks once per thread
4 */
5 /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3 < * Expert Group and released to the public domain. Use, modify, and
4 < * redistribute this code in any way without acknowledgement.
3 > * Expert Group and released to the public domain, as explained at
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7 + import java.util.*;
8   import java.util.concurrent.*;
9   import java.util.concurrent.locks.*;
13 import java.util.*;
10  
11   public final class LockOncePerThreadLoops {
12      static final ExecutorService pool = Executors.newCachedThreadPool();
# Line 21 | Line 17 | public final class LockOncePerThreadLoop
17      static int replications = 20;
18  
19      public static void main(String[] args) throws Exception {
20 <        if (args.length > 0)
20 >        if (args.length > 0)
21              replications = Integer.parseInt(args[0]);
22  
23 <        if (args.length > 1)
23 >        if (args.length > 1)
24              nlocks = Integer.parseInt(args[1]);
25  
26          print = true;
# Line 52 | Line 48 | public final class LockOncePerThreadLoop
48          }
49  
50          final void test() throws Exception {
51 <            for (int i = 0; i < nthreads; ++i)
51 >            for (int i = 0; i < nthreads; ++i)
52                  pool.execute(this);
53              barrier.await();
54              barrier.await();
55              if (print) {
56                  long time = timer.getTime();
57 <                double secs = (double)(time) / 1000000000.0;
57 >                double secs = (double) time / 1000000000.0;
58                  System.out.println("\t " + secs + "s run time");
59              }
60  
# Line 69 | Line 65 | public final class LockOncePerThreadLoop
65  
66          public final void run() {
67              try {
68 <                barrier.await();
68 >                barrier.await();
69                  int sum = v;
70                  int x = 0;
71                  for (int i = 0; i < locks.length; ++i) {
# Line 90 | Line 86 | public final class LockOncePerThreadLoop
86                  barrier.await();
87                  result += sum;
88              }
89 <            catch (Exception ie) {
90 <                return;
89 >            catch (Exception ie) {
90 >                return;
91              }
92          }
93      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines