thread(线).doc

  1. 1、本文档共14页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
thread(线)

thread(线) Multithreading ======================= Thread: a process in a process The difference between threads and processes: Each process requires the operating system to allocate separate memory address space for it. All threads in each process work in the same memory space, which share the same memory space and system resources. There are two ways to build threads: 1. extend the java.lang.Thread class 2. implement the java.lang.Runnable interface The java.lang.Thread class represents the thread class. The two main methods are: 1. run () represents the code executed by the thread at run time 2. start () used to start threads A thread can only be started once. The java.lang.IllegalThreadStateException exception is thrown at the second boot Transition between threads 1. new status. The thread object created with the new statement is in a new state. At the same time, it allocates memory address space only in the heap, just like any other Java object 2. ready state. When a thread is created, the start method is called to start the thread, when the thread enters the ready state. The thread in readiness is in the running pool, waiting for access to CUP 3. run. At this point, the thread takes up CPU and executes the program 4. blocked state. When the thread is blocked, the Java virtual machine does not assign CUP resources to it until the thread is ready again There are three kinds of blocking states: 1. is located in the object waiting pool occlusion: when the thread is running, if the wait method of the A object is executed, the Java virtual machine puts the thread into the waiting pool of the A object 2. block located in the object lock: when the thread is running, trying to get the synchronization lock of the A object, if the A objects synchronization lock has been occupied by another thread, JVM will put the thread into the synchronous lock of the A object. 3. other congestion: when a sleep method is called, or a join method of another thread is called, or a I/O req

文档评论(0)

f8r9t5c + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8000054077000003

1亿VIP精品文档

相关文档