Machine-translated by Google. Questions are authored in English.
Top

Discussion

Consider how ConcurrentHashMap handles concurrent retrieval. Which statement is correct?

  • A.ConcurrentHashMap forbids concurrent reads while any write is in progress.
  • B.ConcurrentHashMap allows retrievals to proceed without blocking.
  • C.ConcurrentHashMap locks the whole map for every read and write.
  • D.ConcurrentHashMap is simply HashMap with every method declared synchronized.

Answer: B

It is built for concurrency rather than wrapped for it: reads generally proceed without locking and writes contend only over part of the table, so throughput holds up under many threads. A Collections.synchronizedMap, by contrast, funnels every call through one lock.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.