equal
deleted
inserted
replaced
34 /* |
34 /* |
35 * @test |
35 * @test |
36 * @bug 6785442 |
36 * @bug 6785442 |
37 * @summary Checks race between poll and remove(Object), while |
37 * @summary Checks race between poll and remove(Object), while |
38 * occasionally moonlighting as a microbenchmark. |
38 * occasionally moonlighting as a microbenchmark. |
39 * @run main RemovePollRace 12345 |
39 * @run main RemovePollRace 1234 |
40 */ |
40 */ |
41 |
41 |
42 import java.util.concurrent.ArrayBlockingQueue; |
42 import java.util.concurrent.ArrayBlockingQueue; |
43 import java.util.concurrent.ConcurrentHashMap; |
43 import java.util.concurrent.ConcurrentHashMap; |
44 import java.util.concurrent.ConcurrentLinkedDeque; |
44 import java.util.concurrent.ConcurrentLinkedDeque; |
54 import java.util.List; |
54 import java.util.List; |
55 import java.util.Queue; |
55 import java.util.Queue; |
56 import java.util.Map; |
56 import java.util.Map; |
57 |
57 |
58 public class RemovePollRace { |
58 public class RemovePollRace { |
59 // Suitable for benchmarking. Overriden by args[0] for testing. |
59 // Suitable for benchmarking. Overridden by args[0] for testing. |
60 int count = 1024 * 1024; |
60 int count = 1024 * 1024; |
61 |
61 |
62 final Map<String,String> results = new ConcurrentHashMap<String,String>(); |
62 final Map<String,String> results = new ConcurrentHashMap<String,String>(); |
63 |
63 |
64 Collection<Queue<Boolean>> concurrentQueues() { |
64 Collection<Queue<Boolean>> concurrentQueues() { |
98 } |
98 } |
99 |
99 |
100 void test(String[] args) throws Throwable { |
100 void test(String[] args) throws Throwable { |
101 if (args.length > 0) |
101 if (args.length > 0) |
102 count = Integer.valueOf(args[0]); |
102 count = Integer.valueOf(args[0]); |
|
103 |
103 // Warmup |
104 // Warmup |
104 for (Queue<Boolean> queue : concurrentQueues()) |
105 for (Queue<Boolean> queue : concurrentQueues()) |
105 test(queue); |
106 test(queue); |
106 results.clear(); |
107 results.clear(); |
107 for (Queue<Boolean> queue : concurrentQueues()) |
108 for (Queue<Boolean> queue : concurrentQueues()) |