当前位置:网站首页>Brief description of the state of the thread
Brief description of the state of the thread
2022-08-08 14:07:00 【qq_25073223】
From:
Introduction to the state of the thread
Multithreading (multithreading) refers to the technology that realizes the concurrent execution of multiple threads from software or hardware.Computers with multi-threading capabilities have hardware support to be able to execute more than one thread at a time, thereby increasing overall processing performance.Systems with this capability include symmetric multiprocessors, multicore processors, and chip-level multiprocessing or simultaneous multithreading processors.In a program, these independently running program fragments are called "threads", and the concept of programming using it is called "multi-threading"
Multi-threading advantages:
1. The use of threads can put the tasks in the program that take up a long time into the background for processing.
2. The user interface can be more attractive. For example, if the user clicks a button to trigger the processing of certain events, a progress bar can pop up to display the processing progress.
3. The running speed of the program may be accelerated.
4. Threads are more useful in the realization of some waiting tasks, such as user input, file reading and writing, and network sending and receiving data.In this case, some precious resources such as memory usage can be released.
5. Multithreading technology also plays a pivotal role in IOS software development
The following author describes the brief description of the state of threads in java, as follows:
Thread includes the following 5 states:
- New state (New): After the thread object is created, it enters the new state, such as: Thread thread = new Thread()
- Ready state (Runnable): Also known as "executable state".After the thread object is created, other threads call the start() method of the object to start the thread.For example, thread.start().A thread in a ready state may be scheduled for execution by the CPU at any time
- Running state (Running): The thread obtains the CPU permission to execute.It should be noted that a thread can only enter the running state from the ready state
- Blocked state (Blocked): The blocked state is that the thread gives up the right to use the CPU for some reason and temporarily stops running.Until the thread enters the ready state, there is no chance to go to the running state.There are three blocking situations: 1. Waiting for blocking -- By calling the thread's wait() method, the thread waits for the completion of a job.2. Synchronous blocking - the thread fails to acquire the synchronized synchronization lock (because the lock is occupied by other threads), it will enter the synchronous blocking state 3. Other blocking - by calling the thread's sleep() or join() or issuing an IWhen a /O request is made, the thread will enter the blocking state.When the sleep() state times out, join() waits for the thread to terminate or times out, or when the I/O processing is complete, the thread re-enters the ready state
- Dead state (Dead): the thread finishes executing or exits the run() method due to an exception, and the thread ends its life cycle
边栏推荐
猜你喜欢
看三年的CRUD程序员如何解决数据库死锁的
【Rust—LeetCode题解】1408.数组中的字符串匹配
KD-SCFNet: More Accurate and Efficient Salient Object Detection Through Knowledge Distillation (ECCV2022)
Talking about the underlying data structure of Redis
HackTheBox | Horizontall
【个人总结】2022.8.7周结
手把手教你设计一个全局异常处理器
Full of dry goods, Yu Jingxin class of the Institute of Information Technology, Chinese Academy of Sciences will help you get academic research and thesis writing skills
全网最全的AItium Designer 16下载资源与安装步骤
更改C盘用户目录下的用户名(亲测有效)
随机推荐
Experience Sharing | Systematic Design and Development of Business Cache
HackTheBox | Horizontall
TS+Hooks二次封装antd Modal,实现可拖拽
[Small Coder Study Room] [NOI Online 2020-2 Beginner Group] Finished: Abominable precision will make you burnt
【小码匠自习室】叛逆的小孩,打死也不改
【LeetCode】761. Special binary sequence
我凭借这份pdf成功拿到了阿里,腾讯,京东等六家大厂offer
Tsinghua | GLM-130B: An Open Bilingual Pre-training Model
论文理解:“Self-adaptive loss balanced Physics-informed neural networks“
活动报名| StreamNative 受邀参与 ITPUB 在线技术沙龙
代码随想录笔记_动态规划_322零钱兑换
【Personal Summary】2022.8.7 Week End
【Rust—LeetCode题解】1.两数之和
更改C盘用户目录下的用户名(亲测有效)
shell三剑客-----awk命令
shell三剑客-----sed命令
医学图像数据增强-归一化
华为云云数据库RDS MySQL 版初试探【华为云至简致远】
更改默认打开应用程序设置
2022-08-07 第五小组 顾祥全 学习笔记 day31-集合-Map集合