我有线程中阻塞退出函数的问题。C++块线程退出信号/函数
DWORD WINAPI thread1Func(LPVOID lpParam)
{
exit(0); // Problem is there
while(true){
printf("runnging");
Sleep(1000);
}
}
int _tmain(int argc, _TCHAR* argv[])
{
int thread1 = 1;
HANDLE thread1Handle = 0;
thread1Handle = CreateThread(0, 0,
thread1Func, &thread1, 0, NULL);
WaitForSingleObject(thread1Handle,0);
system("pause");
return 0;
}
不幸的是,我在main函数中创建的线程调用exit(0)函数。
thread1Func不直接调用exit(0)语句。它被thread1Func调用的函数调用。所以我不能评论或删除这个声明。
我想阻塞线程的退出信号,我该怎么做?
如何阻止后台线程的退出信号?
你不能,afaik。你介意告诉我们什么样的代码是?我的意思是,为什么你不能只是改变代码? – manuell