- 1、本文档共61页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
使用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
您可能关注的文档
最近下载
- 2023年蚌埠市从优秀村(社区)干部中考试录用乡镇机关公务员加分考试真题及答案.pdf VIP
- 【教学创新大赛】《数字信号处理》教学创新成果报告.docx
- 学习领会二十届中央纪委四次全会上重要讲话心得体会.docx VIP
- 各类骨折病人的体位护理.pptx VIP
- 2023年标准化知识题库带答案.pdf
- 黑龙江 2023年肿瘤放射治疗学主治医师考试:肿瘤放射治疗学专业知识真题模拟汇编(共769题).doc VIP
- 浅谈网络购物环境下消费者权益的保护.docx VIP
- 2024年湖南交通职业技术学院单招职业技能测试题库及答案解析.docx VIP
- 9年级体育教案.pdf VIP
- 《田间试验统计》课件——项目三 试验数据调查取样.pptx VIP
文档评论(0)