在线程之间共享数据 [英] Sharing data betwen threads

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

问题描述

嗨.有一个小问题. 1个项目2个班级.我要在每个类之间共享数据的每个类中有1个线程.我将每个线程放入for循环中.一个线程正在发送,另一个线程正在接收.我使用的队列是线程安全的.
问题是:线程1 queue.Enqueue()数据,我看到的是,它用数据加载队列,因为我看的是queue.Count().当线程1加载队列时,它将在线程2上的queue.WaitOne()上执行queue.Set(),但没有任何反应.它不会出队.我在其他2个线程中获得了相同的队列类,使用了相同的技术,并且效果很好?????? :((

最好的给大家.

Hi. Have a litle(BIG) problem. 1 project 2 classes. 1 thread in each class that I want to share data between them. I put each thread in a for loop. 1 thread is sending and the other is receiving. The queue I use is thread safe.
The Problem is: Thread 1 queue.Enqueue() data and what I can see is, it loads the queue with data, because i look with queue.Count(). When thread 1 loads the queue, It does a queue.Set() on thread 2 that is on queue.WaitOne() but nothing is happening. It doesn''t dequeue. I got the same queue class in 2 other threads, used the same technique, and it works fine?????? :((

Best to you all.

推荐答案

我在路上有点.我有某种线程问题.
I got a bit on the way. I´ts some kind of thread problem.


这篇关于在线程之间共享数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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