-
How to externally synchronize hashmap?
-
- Collections.synchronize(new HashMap
()); - Collections.synchronizedMap(new HashMap
()); - HashMap.synchronize(HashMap a);
- HashMap a = new HashMap();
a.synchronize(); - None of these
- Collections.synchronize(new HashMap
Correct Option: B
Collections.synchronizedMap() synchronizes entire map. ConcurrentHashMap provides thread safety without synchronizing entire map.