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);
谢谢^^