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.7 by jsr166, Sat Dec 31 04:10:36 2016 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.concurrent.*;
8 < import java.util.concurrent.locks.*;
9 < import java.util.*;
7 > import java.util.concurrent.CyclicBarrier;
8 > import java.util.concurrent.ExecutorService;
9 > import java.util.concurrent.Executors;
10 > import java.util.concurrent.locks.ReentrantLock;
11  
12   public final class LockOncePerThreadLoops {
13      static final ExecutorService pool = Executors.newCachedThreadPool();
# Line 21 | Line 18 | public final class LockOncePerThreadLoop
18      static int replications = 20;
19  
20      public static void main(String[] args) throws Exception {
21 <        if (args.length > 0)
21 >        if (args.length > 0)
22              replications = Integer.parseInt(args[0]);
23  
24 <        if (args.length > 1)
24 >        if (args.length > 1)
25              nlocks = Integer.parseInt(args[1]);
26  
27          print = true;
# Line 52 | Line 49 | public final class LockOncePerThreadLoop
49          }
50  
51          final void test() throws Exception {
52 <            for (int i = 0; i < nthreads; ++i)
52 >            for (int i = 0; i < nthreads; ++i)
53                  pool.execute(this);
54              barrier.await();
55              barrier.await();
56              if (print) {
57                  long time = timer.getTime();
58 <                double secs = (double)(time) / 1000000000.0;
58 >                double secs = (double) time / 1000000000.0;
59                  System.out.println("\t " + secs + "s run time");
60              }
61  
# Line 69 | Line 66 | public final class LockOncePerThreadLoop
66  
67          public final void run() {
68              try {
69 <                barrier.await();
69 >                barrier.await();
70                  int sum = v;
71                  int x = 0;
72                  for (int i = 0; i < locks.length; ++i) {
# Line 90 | Line 87 | public final class LockOncePerThreadLoop
87                  barrier.await();
88                  result += sum;
89              }
90 <            catch (Exception ie) {
91 <                return;
90 >            catch (Exception ie) {
91 >                return;
92              }
93          }
94      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines