Thread Pool and .IsBackground in .NET

前端 未结 3 1993
慢半拍i
慢半拍i 2021-01-18 03:27

MSDN, as well as many other sources, claim that worker threads in the thread pool are always background.

"Thread pool threads are background threads

3条回答
  •  無奈伤痛
    2021-01-18 04:10

    Thread pool threads are background threads

    Finish that sentence with "they have their IsBackground property initialized to True, unlike threads created with the Thread class."

    Setting it to false could be a bit risky. Threadpool threads are recycled, I'm not so sure that the property will be re-initialized. It is not a property associated with the physical operating system thread, they don't have IsBackground behavior, it is added by the wrapper that the CLR puts around it. So probably yes. Little reason to mess with it though.

提交回复
热议问题