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.