new Thread() and Garbage Collection

后端 未结 4 796
感动是毒
感动是毒 2020-12-09 10:04

I have the following code:

new Thread(new ThreadStart(delegate()
{
    while (true)
    {
        //something
    }
})).Start();

Can garbag

4条回答
  •  春和景丽
    2020-12-09 10:39

    All running timer, threads, thread pool and tasks are marked as root. So they will be garbage collected only when they're done (finished executing) or will be deleted when the application closes.

提交回复
热议问题