1. <i id='IKKPz'><tr id='IKKPz'><dt id='IKKPz'><q id='IKKPz'><span id='IKKPz'><b id='IKKPz'><form id='IKKPz'><ins id='IKKPz'></ins><ul id='IKKPz'></ul><sub id='IKKPz'></sub></form><legend id='IKKPz'></legend><bdo id='IKKPz'><pre id='IKKPz'><center id='IKKPz'></center></pre></bdo></b><th id='IKKPz'></th></span></q></dt></tr></i><div id='IKKPz'><tfoot id='IKKPz'></tfoot><dl id='IKKPz'><fieldset id='IKKPz'></fieldset></dl></div>
  2. <tfoot id='IKKPz'></tfoot>
    • <bdo id='IKKPz'></bdo><ul id='IKKPz'></ul>

    <small id='IKKPz'></small><noframes id='IKKPz'>

    <legend id='IKKPz'><style id='IKKPz'><dir id='IKKPz'><q id='IKKPz'></q></dir></style></legend>

      是什么阻止了 C# 中的线程被收集?

      时间:2023-09-13
        <tbody id='EhBxY'></tbody>

      <i id='EhBxY'><tr id='EhBxY'><dt id='EhBxY'><q id='EhBxY'><span id='EhBxY'><b id='EhBxY'><form id='EhBxY'><ins id='EhBxY'></ins><ul id='EhBxY'></ul><sub id='EhBxY'></sub></form><legend id='EhBxY'></legend><bdo id='EhBxY'><pre id='EhBxY'><center id='EhBxY'></center></pre></bdo></b><th id='EhBxY'></th></span></q></dt></tr></i><div id='EhBxY'><tfoot id='EhBxY'></tfoot><dl id='EhBxY'><fieldset id='EhBxY'></fieldset></dl></div>

          <tfoot id='EhBxY'></tfoot>
          <legend id='EhBxY'><style id='EhBxY'><dir id='EhBxY'><q id='EhBxY'></q></dir></style></legend>

              <small id='EhBxY'></small><noframes id='EhBxY'>

                <bdo id='EhBxY'></bdo><ul id='EhBxY'></ul>

              • 本文介绍了是什么阻止了 C# 中的线程被收集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在 .NET 中,在这段代码之后,什么机制可以阻止 Thread 对象被垃圾回收?

                In .NET, after this code, what mechanism stops the Thread object from being garbage collected?

                new Thread(Foo).Start();
                GC.Collect();
                

                是的,假设 something 引用了该线程是安全的,我只是在徘徊到底是什么.由于某种原因,Reflector 没有向我显示 System.Threading,所以我自己无法挖掘它(我知道 MS 发布了 .NET 框架的源代码,我只是手边没有它).

                Yes, it's safe to assume something has a reference to the thread, I was just wandering what exactly. For some reason Reflector doesn't show me System.Threading, so I can't dig it myself (I know MS released the source code for the .NET framework, I just don't have it handy).

                推荐答案

                运行时只要线程在运行就保持对线程的引用.只要有人仍然保留该引用,GC 就不会收集它.

                The runtime keeps a reference to the thread as long as it is running. The GC wont collect it as long as anyone still keeps that reference.

                这篇关于是什么阻止了 C# 中的线程被收集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:垃圾收集不会减少当前内存使用量 - 在释放模式下.为什么? 下一篇:同步运行 GC.Collect

                相关文章

                <small id='0fkU2'></small><noframes id='0fkU2'>

                <legend id='0fkU2'><style id='0fkU2'><dir id='0fkU2'><q id='0fkU2'></q></dir></style></legend>

                <tfoot id='0fkU2'></tfoot>
                  <bdo id='0fkU2'></bdo><ul id='0fkU2'></ul>

                    <i id='0fkU2'><tr id='0fkU2'><dt id='0fkU2'><q id='0fkU2'><span id='0fkU2'><b id='0fkU2'><form id='0fkU2'><ins id='0fkU2'></ins><ul id='0fkU2'></ul><sub id='0fkU2'></sub></form><legend id='0fkU2'></legend><bdo id='0fkU2'><pre id='0fkU2'><center id='0fkU2'></center></pre></bdo></b><th id='0fkU2'></th></span></q></dt></tr></i><div id='0fkU2'><tfoot id='0fkU2'></tfoot><dl id='0fkU2'><fieldset id='0fkU2'></fieldset></dl></div>