2个线程 访问一个list 其中一个remove操作了 另一个在迭代 假如不用vol修饰 那么在迭代的那个线程可能感知不到modcount的变化啊甚至于说官方认为有volatile是一个BUG?https://bugs.java.com/bugdata...
2 回答

慕容3067478
TA贡献1773条经验 获得超3个赞
Since the modCount mechanism comes with no guarantees, and users of
single-threaded collections do not expect to pay the (high) price
of a volatile write on every modification operation, the volatile
modifier should be removed.
Description里都写的那么清楚了 还有什么可问的?
添加回答
举报
0/150
提交
取消