Home » JAVA Programming » Collections » Question
  1. How to externally synchronize hashmap?
    1. Collections.synchronize(new HashMap());
    2. Collections.synchronizedMap(new HashMap());
    3. HashMap.synchronize(HashMap a);
    4. HashMap a = new HashMap();
      a.synchronize();
    5. None of these
Correct Option: B

Collections.synchronizedMap() synchronizes entire map. ConcurrentHashMap provides thread safety without synchronizing entire map.



Your comments will be displayed only after manual approval.