在Java中映射整数和字符串的正确线程安全集合是什么?ConcurrentHashMap是正确的方法吗?
private volatile ConcurrentHashMap<int, bool> chm;
Run Code Online (Sandbox Code Playgroud)
上述声明有什么问题.Eclipse说"令牌上的语法错误"int",此符号后面的维度"
Mat*_*hen 10
这映射Integer到a String.在Java中,泛型必须使用引用类型(Integer,Boolean等),而不是基元(int,boolean等)
private final ConcurrentHashMap<Integer, String> chm;
Run Code Online (Sandbox Code Playgroud)
我不需要是易失性的,除非你不太可能将多个线程中的新地图放入字段中.地图本身将负责同步突变.
| 归档时间: |
|
| 查看次数: |
3432 次 |
| 最近记录: |