Q: A. netProgramHow many threads have been started at runtime?
A: At least three.
- Start the main thread of Clr and run the main method
- Debugger help thread
- Finalizer thread
ClassProgram {Static VoidMain (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.