标签:
http://blog.sina.com.cn/s/blog_508938e10102v1ig.html
//make thread-safe list List MyStrList = Collections.synchronizedList(new ArrayList()); MyStrList.add("123"); MyStrList.add("abc"); //make thread-safe hashset Set set=Collections.synchronizedSet(new HashSet()); set.add(123); set.add(456); //make thread-safe hashmap Map map=Collections.synchronizedMap(new HashMap()); map.put(1, "thb"); map.put(12, "bill tang");
java 中如何声明线程安全的集合 set, map 和list
标签:
原文地址:http://www.cnblogs.com/whatlonelytear/p/5638082.html