- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
使用windowsthreads编程-杨全胜
* Thread handles left lying around take up memory space. Continuously creating threads without cleaning up the handles when done, could lead to a memory leak. Another possibility would be that the maximum number of threads that can be supported within a process will be reached and no more new threads will be able to be created. Clean up after your threads!! Examples within this talk don’t use this since they are so small and the exit of the process will do the resource reclamation automatically. * ExitThread always kill the thread it called. TerminateThread can kill all kind of Thread. * The independent task in this example is to print the phrase Hello Thread encapsulated into the helloFunc() function. The DWORD WINAPI declaration specifies that this function can be mapped to a thread when you call the CreateThread() function. When the program starts execution, the main (process) thread begins execution of the main() function. The main thread creates a child thread that will execute the helloFunc() function. After creation of the helloFunc thread, the main thread encounters the program termination, which will destroy all the child threads. If the created thread does not have enough time to print Hello Thread before the main thread exits, nothing will be printed from execution of this application. The main thread holds the process information. When the process terminates, all the threads terminate. Therefore, to ensure that the desired printing is accomplished, the main thread must wait for the created thread to finish before it exits. Therefore, to avoid writing applications that spawn threads and end before any useful work begins; you need a mechanism to wait for threads to finish their processing. Question for Discussion: What are the possible outcomes for the above code? Answer: Two possible outcomes: Message Hello Thread is printed on screen. Nothing printed on screen. This outcome is more likely that previous. Main thread is the process and when the
您可能关注的文档
- 离岸工程结构力学的若干问题-力学进展.pdf
- 浦江公共资源交易中心关于.doc
- 健康养生知识50题.pdf
- 案例文字稿样稿.doc
- 制定工艺规程时-模具制造技术-江苏通州中等专业学校.ppt
- 微亿外卖新手指引.pdf
- 水下声学传感器网络研究-信息通信学术期刊网.pdf
- 挤压丝锥结构参数对内螺纹冷挤压成形过程扭矩的影响.pdf
- 多通道声音信号处理-成峰科技-首页.pdf
- 基于机器视觉与敲击振动融合的鸭蛋孵化特性检测-农业机械学报.pdf
- 河海大学电工电子试验教学中心成果汇编-河海大学能源与电气学院.pdf
- 计算机组成原理控制单元的设计101组合逻辑设计102微程序.ppt
- 基于遥感和地统计学方法的小麦生长管理分区米.pdf
- 黄瓜根际土壤及根系的amf菌群多样性研究-广东农业科学.pdf
- 基于损伤的phc桩单轴受拉动态本构模型研究-西安建筑科技大学学报.pdf
- 带权稀疏pca算法及其应用-广西民族大学机构知识库.pdf
- 考虑多项定量描述指标的岩体结构面组数和间距研究-中南大学学报.pdf
- 一企业资质-上海天龙电子有限公司.doc
- 基于支持向量机的水下地形1配导4中适配区划я方法研究.pdf
- 太阳能工程软件polysun5软件简介.pdf
文档评论(0)