我知道ConcurrentHashMap是线程安全的e.g.putIfAbsent,替换等等,但我想知道,下面的代码块是否安全?if (accumulator.containsKey(key)) { //accumulator is a ConcurrentHashMap} else {
accumulator.put(k
我有一个用于生成随机值并将这些随机值放入hashmap的类。但是我已经将测试套件配置为能够执行paralley。所以,我声明了构造器是私有的,是线程安全的这个哈希图。这个机制正确吗?如果它是不正确的,我如何实现它?private RandomData(){}
/* generate random value and put