- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
多线程文档(Multithreaded document)
多线程文档(Multithreaded document)
1. definitions:
Process thread:
Processes and threads are a control flow. A process that usually corresponds to a program. A program can be made up of several different threads.
The process is generally for the operating system. Threads are generally referred to as a program.
Processes are managed by the operating system, while threads are in a program (process).
Simultaneous simultaneous:
A thread is a different execution path in a program. The micro process stops and stops and runs on the macro level. This synchronous operation is called concurrency, but not in the absolute sense. At the same time point, CPU will only have one thread executing.
Multithreading:
In the same application, multiple sequential streams are executed simultaneously. The purpose of multi threading is to maximize the use of CPU resources.
2. create:
First kind
To implement the Runnable interface, there is only one run () method. However, the Runnable interface does not have any thread support, and we must also create instances of the Thread class, which are implemented by the constructor public Thread (Runnable target) of the Thread class.
Public, class, MyThread, implements, Runnable
{
Int, count=1, number;
Public MyThread (int Num)
{
Number = num;
System.out.println (create thread + number);
}
Public, void, run ()
{
While (true)
{
System.out.println (thread + number +: count + count);
If (++count== 6) return;
}
}
Public, static, void, main (String, args[])
{
For (int, I = 0, I, 5, i++)
New Thread (New MyThread (i+1)).Start ();
}
}
Second kinds
Inheriting the Thread class, overriding the method run (). You must start a new thread by executing the start () method of Thread, and if you call the run () method that is a call to method, you will not start a new thread. Simple, but not multiple inheritance.
Public, class, NewThread, extends, Thread
{
Public, void, run ()
{
System.out.println (New thread);
}
Public, static, void, main (String[], args)
{
TwoThread TT
您可能关注的文档
- 吉林舞曲麦词(Jilin dance words).doc
- 同位语从句(Appositive clause).doc
- 同学三十年聚会致辞(Students' thirty years' meeting speech).doc
- 同景地产持续创销售奇迹,成为地产行业的神话(King estate continued to record sales miracle, become the real estate industry myth).doc
- 同步异步知识(Synchronous asynchronous knowledge).doc
- 合伙中国的众筹平台风险分析(Risk analysis of partner raising platforms in China).doc
- 同济医科大学药学专业教学计划 - 华中科技大学(Pharmacy teaching program of Tongji Medical University - Huazhong University of Science and Technology).doc
- 名人里(Celebrity).doc
- 名字游戏(Name game).doc
- 名侦探柯南经典语句(Detective Conan classic sentence).doc
最近下载
- 某住宅楼给水排水设计毕业论文(设计)计算书.doc VIP
- 婴幼儿发展心理学 同伴关系 同伴关系.pptx VIP
- 人教版九年级(初三)道德与法治下册全册教案.pdf VIP
- 会计学原理课程实验(第六版)张志康习题答案解析.pdf
- 20S517- 排水管道出水口.pdf VIP
- Bose博士SoundTouch 300 Soundbar 扬声器说明书.pdf
- 集团数字化中台系统建设项目_用户手册_设备主数据.docx VIP
- 17J008 挡土墙(重力式、衡重式、悬臂式)(最新).pdf VIP
- 具身智能的基础知识(68页 PPT).pptx
- 仪表桥架及保护管安装培训2(2021-03).pptx VIP
原创力文档


文档评论(0)