If I have two threads concurrently modifying a string field on a struct, will I always see one or the other string assigned to the field, but nothing else?
1条回答 默认 最新
- dpztth71739 2016-01-12 17:40关注
No. If you need atomic operations, there is
sync/atomic
.The Go Memory Model will have all the related details. From the top of the Memory Model document:
Programs that modify data being simultaneously accessed by multiple goroutines must serialize such access.
To serialize access, protect the data with channel operations or other synchronization primitives such as those in the
sync
andsync/atomic
packages.本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 Linux操作系统中的,管道通信问题
- ¥15 请问这张multisim图的原理是什么,这是一个交通灯,是课程要求,明天要进行解析,但是我们组没一个人会,所以急要,今天要
- ¥15 ansible tower 卡住
- ¥15 等间距平面螺旋天线方程式
- ¥15 通过链接访问,显示514或不是私密连接
- ¥100 系统自动弹窗,键盘一接上就会
- ¥50 股票交易系统设计(sql语言)
- ¥15 调制识别中这几个数据集的文献分别是什么?
- ¥15 使用c语言对日志文件处理
- ¥15 请大家看看报错原因,为啥会这样