I am running a simple windows console application:- When the control comes at main I dumped the stack--
_ My main thread's stack:
5840 0 Main Thread Main Thread Normal
console.exe!wmain(int argc=1, wchar_t * * argv=0x006831a0)
console.exe!__tmainCRTStartup()
console.exe!wmainCRTStartup()
kernel32.dll!@BaseThreadInitThunk@12()
ntdll.dll!___RtlUserThreadStart@8()
ntdll.dll!__RtlUserThreadStart@8()
__
The above is fine by why do I see this at startup ??:
3740 0 Worker Thread Win32 Thread Normal
Stack:
ntdll.dll!_KiFastSystemCallRet@0()
ntdll.dll!_ZwDelayExecution@8()
ntdll.dll!__LdrpInitialize@8()
ntdll.dll!_LdrInitializeThunk@8()
LdrInitializeThunk is the method to setup a new thread. I did create with VS2008 a plain Win32 console application (no MFC,ATL) and get only one thread. Only when I attach a debugger I get a second one because the debugger injects a thread to enable debugging of the process. Process startup is covered in great detail in the book here where nothing is mentioned that a second thread is needed. Asynchronous Procedure Calls APCs are also not to blame. Perhaps your call stack was created with not all symbols loaded and you wrongly suspect the debugger helper thread as a hidden thread inside your application. When you have a look at your process with process explorer without a debugger you should see only one thread.