简体   繁体   English

在ConcurrentHashMap中,为什么不在段上使用ReentrantReadWriteLock代替ReentrantLock

[英]In ConcurrentHashMap, why don't use ReentrantReadWriteLock in place of ReentrantLock on segment

由于ConcurrentHashMap不能100%确保写操作的一致性(即size() ),因此使用ReentrantReadWriteLock (或通过自定义派生的类)可以提高性能,对吗?

Performance improvement will depend upon kind of operation you want to do. 性能的提高将取决于您要执行的操作。 If you want to read more then yes otherwise while a thread is writing [ie has taken write lock] , no other thread can take read or write lock so performance gain wont be there. 如果您想阅读更多内容,请单击是,否则,在线程正在写时(即已采取写锁定),否则其他线程将无法进行读或写锁定,因此不会有性能提升。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM