2個線程 訪問一個list 其中一個remove操作了 另一個在迭代 假如不用vol修飾 那么在迭代的那個線程可能感知不到modcount的變化啊甚至于說官方認為有volatile是一個BUG?https://bugs.java.com/bugdata...
2 回答

慕容3067478
TA貢獻1773條經(jīng)驗 獲得超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
提交
取消