如果线程完成检查的正确方法? [英] Correct way of checking if threads are done?

查看:122
本文介绍了如果线程完成检查的正确方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用多线程在我与_beginthread应用程序,并马上要等到所有线程完成我有,因为每个线程完成,所以我在一个while循环,直到后来就设置为true全球的bool。必须有这样做的更清洁的方式?

I'm using multithreading in my application with _beginthread and right now to wait until all threads are done I have global bools that get set to true as each thread completes so I'm in a while loop until then. There must be a cleaner way of doing this?

感谢

推荐答案

您可以使用的 WaitForMultipleObjects的来等待线程在主线程完成。

You can use WaitForMultipleObjects to wait for the threads to finish in primary thread.

这篇关于如果线程完成检查的正确方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆