简体   繁体   English

ConcurrentHashMap中的concurrencyLevel

[英]concurrencyLevel in ConcurrentHashMap

What will be the concurrencyLevel if ConcurrentHashMap size increased? 如果ConcurrentHashMap大小增加,concurrencyLevel会是什么?

Suppose initial capacity of ConcurrentHashMap is 16. and default concurrencyLevel will 16. If capacity increased by load factor after some time and now increased capacity is 28. What will be the concurrencyLevel in this case? 假设ConcurrentHashMap的初始容量为16.而默认的concurrencyLevel为16.如果容量在一段时间后按负载因子增加,现在增加的容量为28.在这种情况下,concurrencyLevel是什么?

Gone through with these links as well Segmentation in ConcurrentHashMap and Modifying values in ConcurrentHashMap but still not clear. 继续使用这些链接以及ConcurrentHashMap中的Segmentation在ConcurrentHashMap中 修改值但仍然不清楚。

Thanks in advance. 提前致谢。

There is no reason to think upon reading the documentation that concurrency level can ever change. 没有理由在阅读文档时考虑并发级别可能会发生变化。 It remains what it is set to during object creation. 它仍然是在对象创建过程中设置的内容。 When in doubt, browse the source code: 如有疑问,请浏览源代码:

http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/43cb25339b55/src/share/classes/java/util/concurrent/ConcurrentHashMap.java http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/43cb25339b55/src/share/classes/java/util/concurrent/ConcurrentHashMap.java

it seems that currently all it does is raises the number of bins if initial capacity is less than specified concurrency level. 如果初始容量低于指定的并发级别,它似乎只会增加容器的数量。

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

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