Question
When should a Java developer choose ConcurrentHashMap and Concurrent Collections deliberately?
- Choose ConcurrentHashMap and Concurrent Collections mainly when you want to postpone validation and fix problems manually later.
- Choose ConcurrentHashMap and Concurrent Collections whenever you want the code to look more advanced, even if the design gets less clear.
- Use concurrent collections when many threads need shared access and contention patterns justify specialized structures.
- Choose ConcurrentHashMap and Concurrent Collections only to avoid modeling domain rules explicitly in Java code.
Hint
Think about the production scenario where the choice genuinely improves the code.
Answer and rationale
Correct answer: C. Use concurrent collections when many threads need shared access and contention patterns justify specialized structures.
Use concurrent collections when many threads need shared access and contention patterns justify specialized structures. Interviewers often ask this to see whether you can connect the concept to real design decisions.
Track: Java