需要多线程思想 [英] Mutithreading Idea Needed

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

问题描述

大家好,我在MFC项目中,我在其中使用两个工作线程.一种用于从COM端口读取数据,另一种用于向COM端口写入数据.

我的阅读线程会定期阅读com端口.当我的写入线程需要将数据写入com端口时,我必须停止读取线程,并且在写入操作结束时,我需要启动读取线程.

如果您了解我的知识,那么我是多线程任务的初学者.

在此先感谢
ganeshIT

Hi guys, am in a MFC project in which I use two worker threads. One is for reading data from COM Port and another is for writing data to COM port.

My reading thread read com port periodically. When my writing thread need to write data to com port I have to stop reading thread and at the end of writing operation I need to start the reading thread.

I am beginner to multithreading tasks if you know explain me how can I achieve this.

Thanks in advance
ganeshIT

推荐答案

您必须学习如何同步线程.从此开始:
多线程代码简介 [
You must learn how to synchronize threads. Start with this:
Introduction to Multi-threaded Code[^]


一种实现目标的技术称为信号量.

幸运的是,在The Code Project上有一篇关于此的文章.
初学者的线程同步 [
One technique for achieving your aims is called a semaphore.

As luck would have it there is an article about this here on The Code Project. Thread Synchronization for Beginners[^].


这篇关于需要多线程思想的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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