1 |
– |
/* |
2 |
– |
* @test |
3 |
– |
* @synopsis Exercise multithreaded maps, by default |
4 |
– |
* ConcurrentHashMap. Each thread does a random walk though elements |
5 |
– |
* of "key" array. On each iteration, it checks if table includes key. |
6 |
– |
* If absent, with probablility pinsert it inserts it, and if present, |
7 |
– |
* with probablility premove it removes it. (pinsert and premove are |
8 |
– |
* expressed as percentages to simplify parsing from command line.) |
9 |
– |
*/ |
1 |
|
/* |
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/licenses/publicdomain |
5 |
|
*/ |
6 |
|
|
16 |
– |
|
7 |
|
import java.util.*; |
8 |
|
import java.util.concurrent.*; |
9 |
|
|
10 |
|
public class StringMapLoops { |
11 |
< |
static int nkeys = 1000; |
11 |
> |
static int nkeys = 75000; |
12 |
|
static int pinsert = 60; |
13 |
< |
static int premove = 2; |
13 |
> |
static int premove = 2; |
14 |
|
static int maxThreads = 100; |
15 |
< |
static int nops = 1000000; |
15 |
> |
static int nops = 8000000; |
16 |
|
static int removesPerMaxRandom; |
17 |
|
static int insertsPerMaxRandom; |
18 |
|
|
79 |
|
else |
80 |
|
i = k; |
81 |
|
} |
82 |
+ |
for (int j = 0; j < 10; ++j) { |
83 |
+ |
Thread.sleep(100); |
84 |
+ |
test(1, nkeys, key, mapClass); |
85 |
+ |
// shuffleKeys(key); |
86 |
+ |
} |
87 |
|
pool.shutdown(); |
88 |
|
} |
89 |
|
|
125 |
|
// Uncomment to start with a non-empty table |
126 |
|
// for (int j = 0; j < nkeys; j += 4) // start 1/4 occupied |
127 |
|
// map.put(key[j], key[j]); |
128 |
+ |
|
129 |
|
LoopHelpers.BarrierTimer timer = new LoopHelpers.BarrierTimer(); |
130 |
|
CyclicBarrier barrier = new CyclicBarrier(i+1, timer); |
131 |
|
for (int t = 0; t < i; ++t) |