How does the lock statement ensure intra processor synchronization?

前端 未结 3 1145
萌比男神i
萌比男神i 2021-02-08 04:55

I have a small test application that executes two threads simultaneously. One increments a static long _value, the other one decrements it. I\'ve ensured with

3条回答
  •  情话喂你
    2021-02-08 05:08

    The CLR memory model guarantees (requires) that loads/stores can't cross a fence. It's up to the CLR implementers to enforce this on real hardware, which they do. However, this is based on the advertised / understood behavior of the hardware, which can be wrong.

提交回复
热议问题