Based on. NET program default start thread number explain practical skills

Source: Internet
Author: User
Tags garbage collection

Q: one. NET how many threads did the program start at run time?

Answer: at least 3.

1. Start CLR and run main thread of Main method
2. Debugger Help Thread
3.Finalizer Threads

Copy Code code as follows:

Class Program
{
static void Main (string[] args)
{
Console.WriteLine ("Main thread: {0}",
THREAD.CURRENTTHREAD.MANAGEDTHREADID);
Console.readkey ();
}
}

Typically, the CLR starts more special threads depending on the situation.

Finalizer Thread: This thread is responsible for running GC for garbage collection.
• Concurrent GC Threads: The GC will start more threads and garbage collection according to the situation.
• Server GC Thread: In Server GC mode, the CLR may create GC managed heaps and recycle threads for each kernel of multi-core machines.
• Debugger Help Thread: This thread is responsible for providing help for debuggers such as WinDbg.
AppDomain Uninstall Thread: The CLR may start a work thread to unload an application domain.
threadpool Thread: ThreadPool creates a thread according to 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.