问题描述
好的,我正在处理多线程应用程序.我没有提供任何代码,因为我还没有启动它.我试图找出如何同步数据访问.这将是一个数据树.多个线程可以同时读取该树.但是,一旦线程需要删除节点,就必须锁定所有读取访问权限,直到删除完成.而且一次只能有一个线程删除一个节点.从我的所有研究中,我找到了一种方法,允许通过使用互斥锁一次访问一个线程以进行读取或删除.但是我还没有找到一种在删除时锁定读取的同时允许多个读取的方法.如果有人能指出我的正确方向.好的教程对我有很大帮助.谢谢
Okay I am working on a multithreaded application. I dont have any code to provide as I havent started it. Im trying to find out how to sync data access. It is going to be a data tree. The tree can be read by multiple threads at the same time. But as soon as a thread need to delete a node all read access need to be locked until the delete is complete. And only one thread can delete a node at a time. From all my research I have found ways to allow one thread access at a time for read or delete through use of mutex. But I havent found a way to allow multiple reads at the same time while locking reads while deleting. If someone could just point me in a good direction. To a good tutorial that would help me greatly. Thanks
推荐答案
这篇关于多线程同步问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!