标题:关于线程的问题,大家看看
取消只看楼主
Mycr
Rank: 1
等 级:新手上路
帖 子:203
专家分:0
注 册:2006-9-18
 问题点数:0 回复次数:0 
关于线程的问题,大家看看
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]
搜索更多相关主题的帖子: 线程 
2007-11-24 10:38



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-188033-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.169673 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved