java - ConcurrentHashMap operations -


following lines java docs of concurrenthashmap

this class obeys same functional specification hashtable, , includes versions of methods corresponding each method of hashtable. however, though operations thread-safe, retrieval operations not entail locking, , there not support locking entire table in way prevents access.

what meaning of statement

though operations thread-safe

from above paragraph? can explain example of put() or get() methods?

the concurrenthashmap allows concurrent modification of map several threads without need block them. collections.synchronizedmap(map) creates blocking map degrade performance, albeit ensure consistency (if used properly).

use second option if need ensure data consistency, , each thread needs have up-to-date view of map. use first if performance critical, , each thread inserts data map, reads happening less frequently.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -