您的位置:首页 > 其它

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

2012-12-05 20:17 351 查看
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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐