同步和只读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));
m = Collections.synchronizedMap(new HashMap());
then make an immutable copy using
m2 = Collections.unmodifiableMap(new HashMap(m));
相关文章推荐
- Map的四种外同步方法 姚博文
- ConcurrentHashMap和 CopyOnWriteArrayList提供线程安全性和可伸缩性 以及 同步的集合类 Hashtable 和 Vector Collections.synchronizedMap 和 Collections.synchronizedList 区别缺点
- 133_容器_容器的同步控制与只读设置
- java 定义一个同步map内存去重法
- Java中创建只读容器,同步容器
- 只读map在多线程下面加锁吗
- HashMap、ConcurrentHashMap和SynchronizedMap – 哈希表在Java中的同步处理
- AE学习日记之MapControl与PageLayoutControl图层变化同步
- ArcGIS API for JavaScript 4.2学习笔记[9] 同一种视图不同数据(Map)同步
- ArcGis Server中使用事件方式同步map控件与自定义层的位置
- java实现同步map的几种方法(lock,synchronized,rwlock,ConcurrentHashMap,hashtable,SynchronizedMap)
- HDU_1401——同步双向BFS,八进制位运算压缩,map存放hash
- 基于 equals() 的 键值同步锁: generic key managed concurrent lock map
- Java只读集合与同步集合
- map容器的有条件性同步(get/put有同步,但逻辑上的同步需要依靠更外部的逻辑),并发(ConcurrentHashMap)
- 线程同步模型, 生产者/消费者, 读写同步,线程池,concurrent map.
- 多线程环境下的Map一定要同步吗?
- Map 四种同步方式的性能比较
- MapControl与PageLayoutControl同步一
- 只读设置与同步设置