多线程问题
目的:主线程等待2个子线程结束。
问题:WaitForMultipleObjects() 总是失败,
主线程:
HANDLE h[2];
CWinThread* pThread1 = AfxBeginThread(DownThread1, this);
h[0]=pThread1->m_hThread;
CWinThread* pThread2 = AfxBeginThread(DownThread2, this);
h[1]=pThread2->m_hThread;
while(true)
{
DWORD ret = WaitForMultipleObjects(2,h,TRUE,150);
if(WAIT_OBJECT_0==ret)
{
break;
}
if(WAIT_FAILED==ret)
{
MessageBox("失败");
}
else //时间到了返回,无信号
{
MSG msg;
PeekMessage(&msg,NULL,0,0,PM_REMOVE);
if(WM_QUIT==msg.message)
return false;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
问题:WaitForMultipleObjects() 总是失败,
主线程:
HANDLE h[2];
CWinThread* pThread1 = AfxBeginThread(DownThread1, this);
h[0]=pThread1->m_hThread;
CWinThread* pThread2 = AfxBeginThread(DownThread2, this);
h[1]=pThread2->m_hThread;
while(true)
{
DWORD ret = WaitForMultipleObjects(2,h,TRUE,150);
if(WAIT_OBJECT_0==ret)
{
break;
}
if(WAIT_FAILED==ret)
{
MessageBox("失败");
}
else //时间到了返回,无信号
{
MSG msg;
PeekMessage(&msg,NULL,0,0,PM_REMOVE);
if(WM_QUIT==msg.message)
return false;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
...全文
相关推荐
DateFormat多线程问题
NULL 博文链接:https://zhaoshunxin.iteye.com/blog/1291905
浅析Python多线程下的变量问题
主要介绍了Python多线程下的变量问题,由于GIL的存在,Python的多线程编程问题一直是开发者中的热点话题,需要的朋友可以参考下
多线程死锁问题
死锁问题,java多线程死锁
Python tkinter 多线程 哲学家进餐问题
Python tkinter 多线程 哲学家进餐问题 网上找了好久都没有自己满意的代码,于是自己学了一个,不过这只是个雏形,要想变成你满意的程序,需要靓男靓女们自己的努力啦! 废话不多说,直接上代码! from tkinter import * from PIL import Image,ImageTk import threading from time import sleep import os, random """首先导入必要的模块,由于涉及到导入非gif的图片文件,就要用到PIL库""" """接下来开始写哲学家这个类""" class Philosopher(threading.
个人总结40个Java多线程面试问题和答案
个人总结40个Java多线程面试问题和答案,很全面,让你不再担心多线程的面试问题。


进程/线程/DLL
