问题描述
嗨.有一个小问题. 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.
推荐答案
这篇关于在线程之间共享数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!