如果在阻塞集合类(.NET)中使用块,线程是否存活? [英] Does thread is alive if Take blocks in blocking collection classs (.NET)?

查看:114
本文介绍了如果在阻塞集合类(.NET)中使用块,线程是否存活?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在winform应用程序中阻止收集队列。

在MSDN中,如果没有元素,则表示BlockingCollection.Take()方法调用块。

1)是否意味着该线程将进入等待状态线程状态队列?

2)如果是,该线程可以等待多长时间?

3)当一个新元素被添加到集合时,如何自动发信号通知线程从等待状态进入就绪状态?

4)处于等待状态的线程的生命周期是什么(只要应用程序正在运行,它意味着它是否可用)?



任何人都可以在这个问题上分享您的想法。

Hi
i am working on Blocking collection queue in my winform application.
In MSDN sit is said that BlockingCollection.Take() method call blocks if there is no elements in it.
1)Does it mean the thread will go to the waiting state of threads queue?
2)If yes,how much time does the thread can wait ?
3)How a thread is signalled automatically to come to ready state from wait state when a new element is added to collection?
4)What is the life span of the thread that is in wait state(means is it available as long as the application is running)?

Can anyone please share your ideas on this questions.

推荐答案

1)是。

2)直到集合中有东西。

3)这是Add方法检查等待线程的工作的一部分。

4)应用程序的生命周期。
1) Yes.
2) Until there is something in the collection.
3) It's part of the Add method's job to check for "waiting" threads.
4) Lifetime of the application.


这篇关于如果在阻塞集合类(.NET)中使用块,线程是否存活?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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