By default map is not synchronized in java. To get this we can do following
Getting Synchronized map from hashmap :
From TreeMap :
Getting Synchronized map from hashmap :
HashMap hashMap = new HashMap();
Map map = Collections.synchronizedMap(hashMap);
From TreeMap :
TreeMap treeMap = new TreeMap();
Map map = Collections.synchronizedMap(treeMap);
No comments:
Post a Comment