为什么CreateThread()调用创建线程时,系统设置线程内核对象的引用计数为1,在Create函数返回前是2

CreateThread()调用创建线程时,系统设置线程内核对象的引用计数为1,

在Create函数返回前,将会打开线程句柄,所以线程的内核对象引用计数+1。
creating a new process causes the system to create a process kernel object
and a thread kernel object. At creation time, the system gives each object
an initial usage count of 1. Then, just before CreateProcess returns, the
function opens the process object and the thread object and places the
process-relative handles for each in the hProcess and hThread members of
the PROCESS_INFORMATION structure. When CreateProcess opens these objects
internally, the usage count for each becomes 2.

你可能感兴趣的:(为什么CreateThread()调用创建线程时,系统设置线程内核对象的引用计数为1,在Create函数返回前是2)