Is it good practice to complete ConcurrentHashMap read and write operations with ReentrantLock?

I think the implementation of ConcurrentHashMap already uses ReentrantLock. Therefore, there is no need to use ReentrantLock to access the ConcurrentHashMap object. And this will only add the additional overhead of synchronization. Any comments?

+3
source share
2 answers

What would you (or anyone) want to achieve with this? ConcurrentHashMapalready thread safe as it is. Wrapping with an additional lock code will significantly reduce it, since

  • he doesnโ€™t record reading as such,
  • , .

, ( , ).

ConcurrentHashMap ConcurrentMap . , ( , , ). , ConcurrentHashMap , , , . , , .

Java Generics and Collections, 16.4.

+10

ConcurrentHashMap - /. .

+5

Source: https://habr.com/ru/post/1769572/


All Articles