多线程继承问题? [英] Problem with inheritence in Multi-Threaded ?

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

问题描述

确切地说,互线程应用程序中的继承有什么问题?

Exactly what is the problem with inheritance in Mutual-threaded application ?

推荐答案

没有这样的问题.可以以许多不同的方式组合这两个概念,因为它们并不直接相关.我宁愿说,继承(更确切地说是OOP)可以很好地帮助多线程.这个问题确实没有主题.

There is no such problem. You can combine both concepts in many different ways as they are not directly related. I would rather say, inheritance (more exactly, OOP), can help multithreading very well. This question lacks subject, really.

有关在多线程中使用OOP的基本示例,请看一下我过去的解决方案:
http://www.codeproject.com/Answers/155852/How-to-pass-ref-parameter-to-the-thread#answer2 [启动后更改线程(生产者)的参数 [ ^ ].

For an essential example of use of OOP with multithreading, take a look at my past solutions:
http://www.codeproject.com/Answers/155852/How-to-pass-ref-parameter-to-the-thread#answer2[^],
change paramters of thread (producer) after it started[^].

您可以抽象化ThreadWrapper的不同方面,例如Body,方法是将它们设为虚函数(不要忘记对其进行保护),并生成几个共享相同代码的具体线程包装器类,而无需冗余访问常见的基本行为.

You can abstract out different aspects of the ThreadWrapper, such as Body by making them virtual function (don''t forget to make it protected) and produce several concrete thread wrapper classes sharing the same code, without redundant access to the common fundamental behavior.


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

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