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 */
46
47 import static java.util.concurrent.TimeUnit.MILLISECONDS;
48
49 import java.util.Map;
50 import java.util.SplittableRandom;
51 import java.util.concurrent.CyclicBarrier;
52 import java.util.concurrent.ExecutorService;
53 import java.util.concurrent.Executors;
54 import jdk.testlibrary.Utils;
55
56 public class MapLoops {
57 static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
58 static final int NKEYS = 100000;
59 static int pinsert = 60;
60 static int premove = 2;
61 static int maxThreads = 5;
62 static int nops = 10000; // 1000000
63 static int removesPerMaxRandom;
64 static int insertsPerMaxRandom;
65
66 static final ExecutorService pool = Executors.newCachedThreadPool();
67
68 public static void main(String[] args) throws Exception {
69
70 Class mapClass = null;
71 if (args.length > 0) {
72 try {
73 mapClass = Class.forName(args[0]);
74 } catch (ClassNotFoundException e) {
|
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 */
46
47 import static java.util.concurrent.TimeUnit.MILLISECONDS;
48
49 import java.util.Map;
50 import java.util.SplittableRandom;
51 import java.util.concurrent.CyclicBarrier;
52 import java.util.concurrent.ExecutorService;
53 import java.util.concurrent.Executors;
54 import jdk.test.lib.Utils;
55
56 public class MapLoops {
57 static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
58 static final int NKEYS = 100000;
59 static int pinsert = 60;
60 static int premove = 2;
61 static int maxThreads = 5;
62 static int nops = 10000; // 1000000
63 static int removesPerMaxRandom;
64 static int insertsPerMaxRandom;
65
66 static final ExecutorService pool = Executors.newCachedThreadPool();
67
68 public static void main(String[] args) throws Exception {
69
70 Class mapClass = null;
71 if (args.length > 0) {
72 try {
73 mapClass = Class.forName(args[0]);
74 } catch (ClassNotFoundException e) {
|