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

有没有童鞋遇到过同样的问题:Java集合 modCount为什么不用volatile修饰?

有没有童鞋遇到过同样的问题:Java集合 modCount为什么不用volatile修饰?

慕田峪4524236 2019-06-20 10:29:50
2个线程访问一个list其中一个remove操作了另一个在迭代假如不用vol修饰那么在迭代的那个线程可能感知不到modcount的变化啊甚至于说官方认为有volatile是一个BUG?https://bugs.java.com/bugdata...
查看完整描述

2 回答

?
临摹微笑

TA贡献1982条经验 获得超2个赞

SincethemodCountmechanismcomeswithnoguarantees,andusersof
single-threadedcollectionsdonotexpecttopaythe(high)price
ofavolatilewriteoneverymodificationoperation,thevolatile
modifiershouldberemoved.
Description里都写的那么清楚了还有什么可问的?
                            
查看完整回答
反对 回复 2019-06-20
  • 2 回答
  • 0 关注
  • 360 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

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

帮助反馈 APP下载

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

公众号

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