createthread和beginthread句柄数只增不降
来源:互联网 发布:海尔智能家居网络设置 编辑:程序博客网 时间:2024/04/27 20:47
由于中继服务器句柄增加,随带测试了创建线程句柄数量的问题
1 调用API :createthread,closehandle
线程函数 :func{printf}
执行次数 :1
结果: 句柄 为10
2 调用API :createthread,closehandle
线程函数 :func{printf}
执行次数 :2,200,20000
结果: 句柄 为10,11,12(相同执行次数,句柄也会不同,但在这三值浮动,为固定值)
3 调用API :createthread,closehandle
线程函数 :func{} //注这里空函数
执行次数 :2,200,20000
结果: 和2差不多
4 调用API :_beginthread
线程函数 :func{}
执行次数 :1,2
结果: 句柄都为 10
5 调用API :_beginthread
线程函数 :func{}
执行次数 :20
结果: 句柄 11
6 调用API :_beginthread
线程函数 :func{}
执行次数 :20000
结果: 句柄 13,14
结果来看,就算closehandle或者它自己将引用计数减一,句柄数并一定会随着减少到相应值,而
是保持在一个范围.不过应该没啥关系~~
后记:在msdn看到_beginthread如下的话
It is safer to use _beginthreadex than _beginthread. If the thread spawned by _beginthread exits quickly, the handle returned to the caller of _beginthread may be invalid or, worse, point to another thread. However, the handle returned by _beginthreadex has to be closed by the caller of _beginthreadex, so it is guaranteed to be a valid handle if _beginthreadex did not return an error.
从这句话来看前面句柄数不稳定,或者会上升在于线程函数执行过快,返回的句柄有可能无效导致的
- createthread和beginthread句柄数只增不降
- CreateThread和BeginThread的区别
- beginthread beginthreadex CreateThread 区别
- beginthread还是CreateThread
- beginthread还是CreateThread
- 线程句柄以及createthread()和closehadle()
- 线程句柄以及createthread()和closehadle()
- 线程句柄以及createthread()和closehadle()
- CreateThread()、_beginthreadex()及、AfxBeginThread(),beginthread,beginthreadex
- CreateThread()与beginthread()的区别详细解析
- CreateThread()与beginthread()的区别详细解析
- CreateThread()与beginthread()的区别详细解析
- beginthread和beginthreadex的使用方法
- beginthread和beginthreadex的使用方法
- beginthread和beginthreadex的使用方法
- 在Delphi中创建线程,请一定使用BeginThread()代替CreateThread()创建线程!
- 在Delphi中创建线程,请一定使用BeginThread()代替CreateThread()创建线程!
- 在Delphi中创建线程,请一定使用BeginThread()代替CreateThread()创建线程!
- 每天必须做的事情
- JavaMail(JAVA邮件服务) API详解
- MyISAM几个容易忽视的配置选项
- 最常见的20种VC++编译错误信息集合
- 如何成功的在MSVC6下编译PWLIB1_12_0 /OPENH323 2_4_0
- createthread和beginthread句柄数只增不降
- javascript事件模型框架-eventutil.js
- C++中实现通用数据结构
- 华为往事(十一)---华为的“中南海”
- 整站如何防止SQL注入攻击
- sql通过一个节点ID得到所有子节点
- 华为往事(十二)---C&C08鉴定会
- eclipse 编译器的一个bug
- 华为往事(十三)--“丧权辱国”的协议