Default number of startup threads for. NET programs

Source: Internet
Author: User

Q: How many threads does a. NET program start at runtime?

A: At least three.

1. Start the Main thread of CLR and run the Main method
2. Debugger help thread
3. Finalizer thread

Class Program
{
Static void Main (string [] args)
{
Console. WriteLine ("Main thread: {0 }",
Thread. CurrentThread. ManagedThreadId );
Console. ReadKey ();
}
}
 

Generally, CLR starts more special threads as needed.

• Finalizer thread: This thread runs GC for garbage collection.
• Concurrent GC threads: GC starts more threads for garbage collection based on the situation.
• Server GC thread: In server GC mode, CLR may create GC hosting heap and recycle threads for each core of a multi-core machine.
• Debugger help thread: This thread is responsible for providing help for debuggers like WinDbg.
• AppDomain uninstall thread: CLR may start a working thread to uninstall the application domain.
• ThreadPool thread: ThreadPool creates a thread based on the situation.
 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.