关于线程的问题,大家看看
DWORD WINAPI Fun1Proc(LPVOID lpParameter // thread data
);
int index=0;
void main()
{
HANDLE hThread1;
hThread1=CreateThread(NULL,0,Fun1Proc,NULL,0,NULL);
CloseHandle(hThread1);
while(index++<20)
cout<<"this is main thread!"<<endl;
}
DWORD WINAPI Fun1Proc(
LPVOID lpParameter // thread data
)
{
while(index++<20)
cout<<"this is thread1!"<<endl;
return 0;
}
while(index++<20)为什么设为<20的时候,先运行主线程main
如果我设为while(index++<10) 就只看到[color=#000000]this is thread1! 有点不理解,他们的运行顺序,
[/color]