Get the App
SLTechnology News&Howtos  ›  Development  › 

How many threads does a .NET program start when it is running?

Shulou Source: shulou.com Published: 2022-06-03 05:42:52 11月17日 Update

This article mainly shows you "how many threads a .NET program starts when it is running". It is easy to understand and well-organized. I hope it can help you solve your doubts. Let me lead you to study and learn the article "how many threads are started when a .NET program is running?"

Q: how many threads does a .NET program start when it is running?

A: at least three.

1. The main thread that starts CLR and runs the Main method

two。 Debugger help thread

3.Finalizer thread

The copy code is as follows:

Class Program

{

Static void Main (string [] args)

{

Console.WriteLine ("Main thread: {0}"

Thread.CurrentThread.ManagedThreadId)

Console.ReadKey ()

}

}

Typically, CLR starts more special threads as appropriate.

Finalizer thread: this thread is responsible for running GC for garbage collection.

Concurrent GC threads: GC starts more threads concurrently for garbage collection as appropriate.

Server GC threads: in server GC mode, CLR may create GC managed heaps and recycling threads for each core of a multicore machine.

Debugger help thread: this thread is responsible for providing help to debuggers such as WinDbg.

AppDomain uninstall thread: CLR may start a worker thread to unload the application domain.

ThreadPool ThreadPool threads: ThreadPool creates threads as appropriate.

These are all the contents of the article "how many threads does a .NET program start when it is running?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Threads runs programs help content situations more articles debuggers code garbage servers learning services special objects applications methods easy to understand machines Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Xiaomi NVidia Shulou Technology MySQL