2018-06-29 10:43
浏览 142


I know that in Java writing of int (32bit) is an atomic operation. What about Go? Can go-routine be aborted in the middle when writing to int32, e.g. after writing first 16 bits?

图片转代码服务由CSDN问答提供 功能建议

我知道在Java中编写 int (32位)是一种原子操作。 那去呢? 写入 int32 时,可以在中间中断go-routine的操作,例如 写完前16位之后?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dotj78335 2018-06-29 12:13

    The only way to guarantee atomicity is to use the atomic package, which is great for int32, and many other basic types. For more complex data types, you'll have to use other synchronization mechanisms, because atomicity may not be possible.

    点赞 评论

相关推荐 更多相似问题