1

I just had a look at the java.util.concurrent.ConcurrentHashMap.computeIfAbsent() method and trying to understand this pattern (see the method impl for details):

Node<K,V> r = new ReservationNode<K,V>();
synchronized(r) {
  // ...
}

Syncing on a local variable monitor? By what means does the sync block make sense?

erdal.karaca
  • 693
  • 1
  • 4
  • 20
  • It is not syncing on a local variable. It is syncing on an object which resides in the heap and is referenced from that local variable, and, likely, from other variables too (otherwise syncing has no sense). – Alexei Kaigorodov Aug 31 '17 at 21:46

0 Answers0