您的位置:首页 > 其它

同步和只读Map

2012-06-08 10:48 211 查看
One way to be more confident that the map is not modified during the"read-only" phase is to divide the application into two phases withtwo different maps: First populate the map with a thread-safe implementationlike

m = Collections.synchronizedMap(new HashMap());

then make an immutable copy using

m2 = Collections.unmodifiableMap(new HashMap(m));
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: