Under C# is Int64 use on a 32 bit processor dangerous

前端 未结 6 1229
失恋的感觉
失恋的感觉 2020-12-31 03:41

I read in the MS documentation that assigning a 64-bit value on a 32-bit Intel computer is not an atomic operation; that is, the operation is not thread safe. This means tha

6条回答
  •  北海茫月
    2020-12-31 04:11

    MSDN:

    Assigning an instance of this type is not thread safe on all hardware platforms because the binary representation of that instance might be too large to assign in a single atomic operation.

    But also:

    As with any other type, reading and writing to a shared variable that contains an instance of this type must be protected by a lock to guarantee thread safety.

提交回复
热议问题