简体   繁体   English

GC是.net中的线程吗

[英]Is GC a thread in .net

Garbage Collection is a daemon thread in java. 垃圾回收是Java中的守护程序线程。
I have a great confusion, Is Garbage Collection also a thread in Dot net ?? 我非常困惑,垃圾收集也是Dot net中的一个线程吗?

The garbage collector isn't "a thread" in either .NET or Java. 在.NET或Java中,垃圾收集器都不是“线程”。 On both platforms another thread is (or possibly multiple threads are) used by the garbage collector - to run finalizers on, for example. 在两个平台上,垃圾收集器都使用了另一个线程(或可能使用了多个线程),例如,在其上运行终结器。 The actual garbage collection could be executed on separate threads, too. 实际的垃圾回收可以在单独的线程上执行。 But that doesn't mean that the garbage collector is a daemon thread, any more than a web server is a thread. 但这并不意味着垃圾收集器守护程序线程,而不仅仅是Web服务器是线程。

(If you were just wanting to know whether the garbage collector in .NET required at least one thread in addition to any threads that your application creates, the answer is yes... but you need to be clear in your mind about what exactly you're interested in.) (如果您只是想知道.NET中的垃圾收集器除您的应用程序创建的任何线程之外是否还需要至少一个线程,答案是肯定的……但是您需要清楚自己到底要做什么。感兴趣。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM