MultiThreading与同步问题 [英] MultiThreading issues with synch

查看:72
本文介绍了MultiThreading与同步问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我使用AfxbeginThread API创建了10个线程。



但是我想要一次启动所有10个线程,我不想一个接一个地启动线程。



任何人都可以帮助实现。< br $>




问候,

Ranjith

Hi There,

I have created for 10 threads using AfxbeginThread API.

but i wants to start all 10 threads at a time, i don''t wants to start the thread one by one.

Can any one can help how to implement.


Regards,
Ranjith

推荐答案

这很容易做到。在主程序体(主线程)中创建一个事件对象 [ ^ ]初始状态为无信号。将事件句柄传递给所有线程。然后在所有线程例程中指定WaitForSingleObject()以等待事件发出信号。创建所有线程后,使用SetEvent()将事件置于信号状态。所有线程都将继续执行。
It is very easy to do. In the main program body (main thread) create an Event Object[^] with the initial state nonsignaled. Pass the event handle to all your threads. Then in all the thread routines specify WaitForSingleObject() to wait for the event to become signaled. Once you have created all the threads, put the event to signaled state using SetEvent(). All your threads will continue execution.


这篇关于MultiThreading与同步问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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