在主线程new的变量,在子线程中释放,大约几万次的时候会崩溃,说内存非法访问,不能为read。
不知道什么原因,也不知道怎么修改。求助!// 子线程
DWORD WINAPI thread1(PVOID p)
{
int * x = (int *)p;
delete x;
return 0;
}// 主线程
while ( 1 )
{
int * x = new int;
CloseHandle(CreateThread(0, 0, thread1, x, 0, 0));
//delete x;  // 如果在这里delete不会出问题
}