程序崩溃
#include <windows.h>
#include <iostream.h>
DWORD WINAPI ThreadProc(
LPVOID lpParameter // thread data
);
int index = 0;
void main()
{
HANDLE hThread1;
hThread1 = CreateThread(NULL,0,ThreadProc,NULL,0,NULL);
CloseHandle(hThread1);
while(index++ < 1000)
cout<<"main thread is running"<<endl;
// Sleep(10);
// return 0;
}
DWORD WINAPI ThreadProc(
LPVOID lpParameter // thread data
)
{
while(index++ < 1000)
cout<<" thread1 is running"<<endl;
return 0;
}
这段代码运行起来有时候崩溃,有时候却又正常,这是什么情况的呀???
我看不出哪里有问题呀?