- 1、本文档共34页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
[计算机软件及应用]ThreadPool
Thread Pooling CHAPTER
13
IN THIS CHAPTER
• Benefits of Thread Pooling 308
• Considerations and Costs of Thread
Pooling 308
• A Generic Thread Pool: ThreadPool 309
• A Specialized Worker Thread Pool:
HttpServer 319
Techniques
308
PART II
When design situations arise that could benefit by using many short-lived threads, thread
pooling is a useful technique. Rather than create a brand new thread for each task, you can
have one of the threads from the thread pool pulled out of the pool and assigned to the task.
When the thread is finished with the task, it adds itself back to the pool and waits for another
assignment.
In this chapter, I present two examples that use thread pooling. One creates a pool of threads
that can be generically used to run Runnable objects. The other creates a pool of threads for
servicing requests that come into a simple Hypertext Transfer Protocol (HTTP) server (a Web
page server).
Benefits of Thread Pooling
Thread pooling saves the virtual machine the work of creating brand new threads for every
short-lived task. In addition, it minimizes overhead associated with getting a thread started and
cleaning it up after it dies. By creating a pool of threads, a single thread from the pool can be
recycled over and over for different tasks.
With the thread pooling technique, you can reduce response time because a thread is already
constructed and started and is simply waiting for its next task. In the case of an HTTP server,
an available thread in the pool can deliver each new file requested. Without pooling, a brand
new thread would have t
您可能关注的文档
最近下载
- 2025年中国铁路武汉局集团有限公司招聘毕业生(四)【135人】笔试参考题库附带答案详解.docx
- 最新高二语文下学期期末试卷附答案一套.docx VIP
- 外研版高中《英语》(新标准)必修二Unit6 单元整体教学设计附作业设计.docx
- 毛概电子书.doc
- 紫外线钣金灰行业报告.pptx
- 外研版高中《英语》(新标准)必修二Unit5 单元整体教学设计附作业设计.doc
- CQC13464225-2024电力储能用锂离子电池安全与性能认证规则.pdf
- 外研版高中《英语》(新标准)必修二Unit1 单元整体教学设计附作业设计.doc
- 洪洞悦昌煤业副斜井施工组织设计方案.docx
- (四调)武汉市2025届高中毕业生四月调研考试 数学试卷(含答案详解).pdf
文档评论(0)