在Golang中并发访问uint64的方式

huangapple go评论63阅读模式
英文:

concurrent access to a uint64 in golang

问题

如果多个goroutine访问一个uint64变量,读取操作将永远不会得到除写入到该uint64变量的值之外的其他值。这个说法正确吗?

英文:

If multiple goroutines access one uint64, the read will never get some other value than the ones that are written to that uint64.
Is this correct?

答案1

得分: 2

这是正确的吗?

不,这在任何情况下都是错误的。

绝对不能编写带有数据竞争的代码。这个"绝对不能"是不可商议的。

英文:

> Is this correct?

No, this is plain and totally wrong in each and every case.

You must not write code with data races. This "must not" is not negotiable.

huangapple
  • 本文由 发表于 2022年2月20日 21:41:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/71194981.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定