判断ConcurrentHashMap的putIfAbsent方法中是否真正执行了'put'操作?

Determine if 'put' operation actually executed in putIfAbsent method of ConcurrentHashMap?

想知道'put'操作是否真的在ConcurrentHashMap的putIfAbsent方法中执行

这就是我想要的:

if(map.putIfAbsent(Key,Value)){//Clearly this is wrong
  return true;
}

//other operation

return false;
如果不存在关联键或键的值为空,

Map#putIfAbsent 将 return 为空。否则它将 return 现有值。

V resultOfPut = map.putIfAbsent(key, value);

if (resultOfPut == null) {
    // was able to put
} else {
    // was not able to put, value already exists
}