In C#, How do prevent a race condition when multiple threads are writing
to/reading from the same variable? How do you do this in C++?
請問各位有更精簡的回答嗎?
C++
static CRITICAL_SECTION cs;
EnterCriticalSection(&cs);
XXX();
LeaveCriticalSection(&cs);
C#
Static object locker=new object();
Monitor.Enter(locker);
XXXX();
Monitor.Exit(locker);
謝謝^^