C++多线程信号量,互斥
windows 编程,多线程
临界区:
CRITICAL_SECTION cs; //相当于给该代码段加了一把锁,其它线程不可访问,直到当前线程释放资源
InitializeCriticalSection(&cs);
//线程1:
EnterCriticalSection(&cs);
do something...
LeaveCriticalSection(&cs);
//线程2:
EnterCriticalSection(&cs);
do something
LeaveCriticalSection(&cs);
//最后:
DeleteCriticalSection(&cs);