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?
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.