为何我设置了线程优先级没有起到作用?代码如下:
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;
}
运行后,发现结果如下
两个本该不同优先级的线程居然交互运行了,和没改变优先级一样?WHY??
求高手指导,不胜感激啊?我是XP系统
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;
}
运行后,发现结果如下
两个本该不同优先级的线程居然交互运行了,和没改变优先级一样?WHY??
求高手指导,不胜感激啊?我是XP系统
解决方案 »
- 把动态库做成COM是不是会方便一些啊?
- richedit里打回车,总有系统警告“咚”的声音,请问如何去掉这个声音?
- 在用::SetWindowText(HWND,LPCTSTR)中的hWnd改从那个函数取得?例如要改变static Text或者Edit Box的值。
- 郁闷!!为什么sql语句的create table的表名不能有"."、"-"字符,而在ACCESS中添加表时可以?
- 域名解析的问题!
- 如何用CBitmapButton???????
- 用MFC实现插入法排序、起泡法改进算法排序
- 网络监控问题
- 请教:SW_SHOW和m_nCmdShow有什么差别?
- 仅仅用construct来构建的clistctrl对象是不是不能直接用亚,是不是一定要creat亚
- VC实现网页POST功能如何实现?
- 求大侠指教!怎么获取主对话框和子对话框的坐标!
Idle thread is running!
Idle thread is running!
Normal thread is running!
Idle thread is running!
Normal thread is running!
Idle thread is running!
Normal thread is running!
Normal thread is running!
Idle thread is running!...
DWORD WINAPI ThreadIdle(LPVOID lpParam)
{
int i=0;
while (i++<10)
{
printf("Idle thread is running!\n");
}
return 0;
}DWORD WINAPI ThreadNormal(LPVOID lpParam)
{
int i=0;
while (i++<10)
{
printf("Normal thread is running!\n");
}
return 0;
}