Collections和Collection的区别:
集合的工具类:Collections是类,封装了Set,List,Map操作的工具方法。
常用的集合类:
HashSet/ArrayList/HashMap在多线程情况下都不安全的,
解决方案:
List list =Collections.synchronizedList(new ArrayList());
Map map =Collections.synchronizedMap(new HashMap());
Set set=Collections.synchronizedSet(new HashSet());
要做迭代时得使用synchronized
传入一个不安全的线程,返回一个安全的线程
浙公网安备 33010602011771号