为什么还能运行线程1呢?
# include <windows.h>
# include <iostream.h>
DWORD WINAPI FunProc1(LPVOID lpParameter);
void main()
{ int i=0;
HANDLE thThread1;
thThread1=CreateThread(NULL,0,FunProc1,NULL,0,NULL);
CloseHandle(thThread1);
while(i++<100)
{cout<<"Main Thread is running"<<endl<<endl;
}
cout<<endl<<"the main number is: "<<i<<endl;
}
DWORD WINAPI FunProc1(LPVOID lpParameter)
{ int j=0;
while(j++<100)
{ cout<<"thThread1 is running"<<endl<<endl;
}
cout<<"the 1 number is:"<<j<<endl;
return 0;
}
同时,各输出结果有时为连续出现,有时两结果各一成一组出现。不是应两结果各自成组出现并交替出现吗?