24 * This file is available under and governed by the GNU General Public
25 * License version 2 only, as published by the Free Software Foundation.
26 * However, the following notice accompanied the original version of this
27 * file:
28 *
29 * Written by Doug Lea with assistance from members of JCP JSR-166
30 * Expert Group and released to the public domain, as explained at
31 * http://creativecommons.org/publicdomain/zero/1.0/
32 */
33
34 /*
35 * @test
36 * @bug 4486658
37 * @summary Exercise multithreaded maps, by default ConcurrentHashMap.
38 * Multithreaded hash table test. Each thread does a random walk
39 * though elements of "key" array. On each iteration, it checks if
40 * table includes key. If absent, with probability pinsert it
41 * inserts it, and if present, with probability premove it removes
42 * it. (pinsert and premove are expressed as percentages to simplify
43 * parsing from command line.)
44 * @library /lib/testlibrary/
45 * @run main/timeout=1600 MapLoops
46 */
47
48 import static java.util.concurrent.TimeUnit.MILLISECONDS;
49
50 import java.util.List;
51 import java.util.Map;
52 import java.util.SplittableRandom;
53 import java.util.concurrent.CopyOnWriteArrayList;
54 import java.util.concurrent.CyclicBarrier;
55 import java.util.concurrent.ExecutorService;
56 import java.util.concurrent.Executors;
57 import jdk.testlibrary.Utils;
58
59 public class MapLoops {
60 static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
61 static int nkeys = 1000; // 10_000
62 static int pinsert = 60;
63 static int premove = 2;
64 static int maxThreads = 100;
65 static int nops = 10000; // 100_000
66 static int removesPerMaxRandom;
67 static int insertsPerMaxRandom;
68
69 static final ExecutorService pool = Executors.newCachedThreadPool();
70
71 static final List<Throwable> throwables = new CopyOnWriteArrayList<>();
72
73 public static void main(String[] args) throws Exception {
74
75 Class mapClass = null;
76 if (args.length > 0) {
77 try {
|
24 * This file is available under and governed by the GNU General Public
25 * License version 2 only, as published by the Free Software Foundation.
26 * However, the following notice accompanied the original version of this
27 * file:
28 *
29 * Written by Doug Lea with assistance from members of JCP JSR-166
30 * Expert Group and released to the public domain, as explained at
31 * http://creativecommons.org/publicdomain/zero/1.0/
32 */
33
34 /*
35 * @test
36 * @bug 4486658
37 * @summary Exercise multithreaded maps, by default ConcurrentHashMap.
38 * Multithreaded hash table test. Each thread does a random walk
39 * though elements of "key" array. On each iteration, it checks if
40 * table includes key. If absent, with probability pinsert it
41 * inserts it, and if present, with probability premove it removes
42 * it. (pinsert and premove are expressed as percentages to simplify
43 * parsing from command line.)
44 * @library /test/lib
45 * @run main/timeout=1600 MapLoops
46 */
47
48 import static java.util.concurrent.TimeUnit.MILLISECONDS;
49
50 import java.util.List;
51 import java.util.Map;
52 import java.util.SplittableRandom;
53 import java.util.concurrent.CopyOnWriteArrayList;
54 import java.util.concurrent.CyclicBarrier;
55 import java.util.concurrent.ExecutorService;
56 import java.util.concurrent.Executors;
57 import jdk.test.lib.Utils;
58
59 public class MapLoops {
60 static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
61 static int nkeys = 1000; // 10_000
62 static int pinsert = 60;
63 static int premove = 2;
64 static int maxThreads = 100;
65 static int nops = 10000; // 100_000
66 static int removesPerMaxRandom;
67 static int insertsPerMaxRandom;
68
69 static final ExecutorService pool = Executors.newCachedThreadPool();
70
71 static final List<Throwable> throwables = new CopyOnWriteArrayList<>();
72
73 public static void main(String[] args) throws Exception {
74
75 Class mapClass = null;
76 if (args.length > 0) {
77 try {
|