← Quiz: Java Concurrency Utilities: all 10 questions
Quiz: Java Concurrency Utilities · Question 10 of 10
What is the main advantage of ConcurrentHashMap over a HashMap wrapped in synchronized blocks?
What is the main advantage of ConcurrentHashMap over a HashMap wrapped in synchronized blocks?
- A.It keeps keys sorted
- B.It allows null keys
- C.It never uses any locking at all
- D.Threads working on different keys rarely block each other, so it scales better
Answer & explanation
Correct answer: Threads working on different keys rarely block each other, so it scales better
ConcurrentHashMap avoids one big lock for the whole map, so many threads can read and update at once.
Can you get the rest right without peeking?
Take the timed Quiz: Java Concurrency Utilities quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →