我试图在ConcurrentHashMap中的一个对象中递增一个值,但它总是给出意外的输出。我也尝试过使用AtomicInteger,但它是一样的。预期的输出是John和Doe各有100个计数。这在没有Data对象作为值的情况下工作得很好。导入java.util.concurrent.atomic.AtomicInteger; public class Data {
private AtomicInteger</em
private final ConcurrentHashMap<Float, VoteItem> datum = new ConcurrentHashMap<>();
datum.putIfAbsent(graduation, new VoteItem(graduation, new AtomicInteger(0))VoteItem.getNum()返回一个AtomicInteger?还是有更好的
map = hz.getMap("my-distributed-map");当我试图增加计数器(AtomicInteger编辑:本例适用于典型的javaconcurrentHashMap。private final ConcurrentMap<Long, AtomicInteger> map = new ConcurrentHashMap&