第55页 程序清单4-8
public Map<String, Point> getLocations() {
return Collections.unmodifiableMap(
new HashMap<String, Point>(locations));
}
代码上方有一句话:
其中只返回一个HashMap,因为getLocations并不能保证返回一个线程安全的Map。
getLocations到底是不是线程安全,希望对并发了解可以给予一些指点,谢谢
getLocations
非线程安全。但是``返回的集合是只读集合,故返回的map
是线程安全的。oracle官方文档解释如下: