为了账号安全,请及时绑定邮箱和手机立即绑定

Java集合 modCount为什么不用volatile修饰?

Java集合 modCount为什么不用volatile修饰?

犯罪嫌疑人X 2019-04-26 18:15:55
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里都写的那么清楚了 还有什么可问的?


查看完整回答
反对 回复 2019-05-19
  • 2 回答
  • 0 关注
  • 554 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号