多线程情况下,使用concurrency::wait() 会发生内存暴涨,测试代码如下
#include "stdafx.h"
#include "concrt.h"
#include
#include
using concurrency::event;
static event s_iEvent;
HANDLE s_hThread1(NULL);
HANDLE s_hThread2(NULL);
static unsigned _stdcall testThread(void* pParam)
{
while (true)
{
s_iEvent.set();
s_iEvent.wait(200);
s_iEvent.reset();
}
return 0;
}
int main()
{
s_hThread1 = (HANDLE)_beginthreadex(NULL, 0, &testThread, NULL, 0, NULL);
s_hThread2 = (HANDLE)_beginthreadex(NULL, 0, &testThread, NULL, 0, NULL);
while (1);
return 0;
}