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 |
|
* @test |
8 |
|
* @summary basic safety and liveness of ReentrantLocks, and other locks based on them |
9 |
|
*/ |
10 |
|
|
11 |
+ |
import java.util.*; |
12 |
|
import java.util.concurrent.*; |
13 |
|
import java.util.concurrent.locks.*; |
13 |
– |
import java.util.*; |
14 |
|
|
15 |
|
public final class UncheckedLockLoops { |
16 |
|
static final LoopHelpers.SimpleRandom rng = new LoopHelpers.SimpleRandom(); |
49 |
|
oneTest(i, iters / i); |
50 |
|
Thread.sleep(100); |
51 |
|
} |
52 |
– |
|
52 |
|
} |
53 |
|
|
54 |
|
static void oneTest(int nthreads, int iters) throws Exception { |
117 |
|
System.out.print("FairRReadWriteLock "); |
118 |
|
new FairReentrantReadWriteLockLoop().test(v, nthreads, fairIters); |
119 |
|
Thread.sleep(10); |
121 |
– |
|
120 |
|
} |
121 |
|
|
122 |
|
abstract static class LockLoop implements Runnable { |
401 |
|
|
402 |
|
} |
403 |
|
|
406 |
– |
|
404 |
|
private static class FairReentrantReadWriteLockLoop extends LockLoop { |
405 |
|
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); |
406 |
|
final int loop(int n) { |