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

Comparing jsr166/src/test/loops/CancelledLockLoops.java (file contents):
Revision 1.4 by jsr166, Thu Oct 29 23:09:07 2009 UTC vs.
Revision 1.10 by jsr166, Sat Dec 31 04:10:36 2016 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
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.Arrays;
8 > import java.util.Collections;
9 > import java.util.Random;
10 > import java.util.concurrent.BrokenBarrierException;
11 > import java.util.concurrent.CyclicBarrier;
12 > import java.util.concurrent.ExecutorService;
13 > import java.util.concurrent.Executors;
14 > import java.util.concurrent.locks.ReentrantLock;
15  
16   public final class CancelledLockLoops {
17      static final Random rng = new Random();
# Line 26 | Line 31 | public final class CancelledLockLoops {
31              try {
32                  new ReentrantLockLoop(i).test();
33              }
34 <            catch(BrokenBarrierException bb) {
34 >            catch (BrokenBarrierException bb) {
35                  // OK, ignore
36              }
37          }
# Line 51 | Line 56 | public final class CancelledLockLoops {
56                  threads[i] = new Thread(this);
57              for (int i = 0; i < threads.length; ++i)
58                  threads[i].start();
59 <            Thread[] cancels = (Thread[]) (threads.clone());
59 >            Thread[] cancels = threads.clone();
60              Collections.shuffle(Arrays.asList(cancels), rng);
61              barrier.await();
62              Thread.sleep(TIMEOUT);
# Line 64 | Line 69 | public final class CancelledLockLoops {
69              barrier.await();
70              if (print) {
71                  long time = timer.getTime();
72 <                double secs = (double)(time) / 1000000000.0;
72 >                double secs = (double) time / 1000000000.0;
73                  System.out.println("\t " + secs + "s run time");
74              }
75  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines