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.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(); |
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 |
|
|