How does ConcurrentHashMap work internally?

前端 未结 6 739
傲寒
傲寒 2020-12-02 07:05

I was reading the official Oracle documentation about Concurrency in Java and I was wondering what could be the difference between a Collection returned by

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 07:27

    Returned by synchronizedCollection() is an object all methods of which are synchronized on this, so all concurrent operations on such wrapper are serialized. ConcurrentHashMap is a truly concurrent container with fine grained locking optimized to keep contention as low as possible. Have a look at the source code and you will see what it is inside.

提交回复
热议问题