标题:windows 程序设计2 中的例子 一点疑惑
只看楼主
lxh553503571
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2013-11-17
结帖率:33.33%
已结贴  问题点数:10 回复次数:1 
windows 程序设计2 中的例子 一点疑惑
#include"windows.h"
#include"stdio.h"
DWORD WINAPI ThreadIdle(LPVOID lpParam) //03PriorityDemoG
{
    int i=0;
    while(i++<3)
        printf("Idle Thread is running\n");
    return 0;
}
DWORD WINAPI ThreadNormal(LPVOID lpParam)
{
    int j=0;
    while(j++<3)
        printf("normal Thread is running\n");
        return 0;
}

int main(int argc, char* argv[])
{
DWORD dwThreadID;
HANDLE h[2];
h[0]=::CreateThread(NULL,0,ThreadIdle,NULL,CREATE_SUSPENDED,&dwThreadID);
::SetThreadPriority(h[0],THREAD_PRIORITY_IDLE);
::ResumeThread(h[0]);
h[1]=::CreateThread(NULL,0,ThreadNormal,NULL,0,&dwThreadID);
::WaitForMultipleObjects(2,h,TRUE,INFINITE);
::CloseHandle(h[0]);
::CloseHandle(h[1]);
return 0;
}
这个是windows 程序设计2的代码 线程优先级别代码
我的运行结果是
Idle Thread is running
Idle Thread is running
Idle Thread is running
normal Thread is running
Idle Thread is running
normal Thread is running
normal Thread is running
Press any key to continue

而windows 程序设计2 这本书输出结果是
normal Thread is running
normal Thread is running
normal Thread is running
Idle Thread is running
Idle Thread is running
Idle Thread is running
Press any key to continue
请大侠们看一下是怎么回事 是否是我的编译器有问题
搜索更多相关主题的帖子: windows 程序设计 running include return 
2013-12-17 23:55
yuccn
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:何方
等 级:版主
威 望:167
帖 子:6809
专家分:42393
注 册:2010-12-16
得分:10 
我晕~~

和线程调度有关。这个没有标准的,和书上不一样很正常的

我行我乐
我的博客:
http://blog.yuccn. net
2013-12-18 08:22



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




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

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