我有線程中阻塞退出函數的問題。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