Are Reference Assignments Truly Atomic - Even On a 64 Bit Machine?
Just wondered if the above is true or whether reference assignments are split into two operations
Is this the reason you need to use Interlocked.Exchange
?
Can anyone confirm?
I am talking about pointer assignment here - Is t开发者_StackOverflow社区hat truly atomic?
It depends on the type. For example Int64 assignments are not atomic in x86 mode and atomic in x64 mode. Assigning a string
is atomic as it is a reference type and you are assigning a pointer and the size of the pointer is either 4 or 8 bytes depending on whether you are running on x86 or x64 bit mode.
精彩评论