As for ConcurrentHashMap, what does the following mean?

Directly from ConcurrentHashMap javadocs :

The allowed concurrency among update operations is controlled by the optional concurrencyLevel constructor argument (default 16), which is used as a hint for internal calibration. The table is internally separated to try to allow the specified number of concurrent updates without hesitation. Since the placement in the hash tables is essentially random, the actual concurrency will vary.

I do not understand when they say: "which is used as a hint for internal calibration." Shouldn't size be determined by capacity and not by concurrencyLevel?

+4
source share
1 answer

the table is internally divided - this means that they divide the table into ConcurrencyLevel divisions in the hope that they will be able to do many simultaneous updates without any collisions.

there is no guarantee, however, that hashed data will fall nicely in these sections.

+2
source

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


All Articles