import java.util.Collections;
public class CollectionsDemo { public static void main(String[] args) { // create map Map<String,String> map = new HashMap<String,String>(); // populate the map map.put("1","a"); map.put("2","b"); map.put("3","c"); // create a synchronized map Map<String,String> synmap = Collections.synchronizedMap(map);//当map需要get的时候加上Collections.synchronizedMap就可以了 System.out.println("Synchronized map is :"+synmap); } }