当前位置:网站首页>Play with concurrency: draw a thread state transition diagram
Play with concurrency: draw a thread state transition diagram
2022-07-02 04:05:00 【Java knowledge hall】

Thread state transition
The simple thread state is shown below
Java Thread There is an enumeration inner class inside the thread State, Defined Java The state of the thread language
- NEW( Initialization status )
- RUNNABLE ( Can run / Running state )
- BLOCKED( Blocked state )
- WAITING ( Wait indefinitely )
- TIMED_WAITING( Sometimes it's time to wait )
- TERMINATED( Termination status )
Java The blocking state at the operating system level is subdivided into BLOCK,WAITING,TIMED_WAITING Three states
NEW: New state , The state in which a thread is created but not started . There are three ways to create threads
- Inherit Thread class
- Realization Runnable Interface
- Realization Callable Interface
The most common way we use it is by implementing interfaces ,Runnable and Callable The differences between interfaces are as follows
- Runnable Unable to get return value , and Callable Can get the return value
- Runnable Can't throw exception , and Callable You can throw an exception
RUNNABLE( Ready state ): call start After running the state before
RUNNING( Running state ): The thread is running
BLOCKED( Blocked state ): Enter the following state , There are several situations
- BLOCK( Synchronous blocking ): The lock is occupied by another thread , Waiting to enter synchronized Method or code block
- WAITING( Active blocking ): perform Object.wait(),Thread.join() etc.
- TIMED_WAITING( Waiting for a jam ): perform Object.wait(long),Thread.sleep(long) etc.
DEAD( Termination status ): Thread execution completed
Finally, various methods are added to the thread state diagram 
The functions of various methods in the figure will be analyzed in detail in subsequent chapters
Reference blog
[1]https://blog.csdn.net/pange1991/article/details/53860651
边栏推荐
- The 6th Blue Bridge Cup single chip microcomputer provincial competition
- Sorted out an ECS summer money saving secret, this time @ old users come and take it away
- 集成底座方案演示说明
- pip 安装第三方库
- WPViewPDF Delphi 和 .NET 的 PDF 查看组件
- Pandora IOT development board learning (HAL Library) - Experiment 2 buzzer experiment (learning notes)
- Which is better, industrial intelligent gateway or edge computing gateway? How to choose the right one?
- Nacos 配置中心整体设计原理分析(持久化,集群,信息同步)
- Dare to go out for an interview without learning some distributed technology?
- "No war on the Western Front" we just began to love life, but we had to shoot at everything
猜你喜欢

Jetpack之LiveData扩展MediatorLiveData

First acquaintance with P4 language
![[tips] use Matlab GUI to read files in dialog mode](/img/51/6d6051836bfc9caa957d0275245bd3.png)
[tips] use Matlab GUI to read files in dialog mode

【IBDFE】基于IBDFE的频域均衡matlab仿真

Cloud service selection of enterprises: comparative analysis of SaaS, PAAS and IAAs

FAQ | FAQ for building applications for large screen devices

Force buckle 540 A single element in an ordered array

Lei Jun wrote a blog when he was a programmer. It's awesome

MySQL advanced SQL statement 2

《动手学深度学习》(二)-- 多层感知机
随机推荐
MySQL error: expression 1 of select list is not in group by claim and contains nonaggre
【直播回顾】战码先锋首期8节直播完美落幕,下期敬请期待!
Is the product of cancer prevention medical insurance safe?
Www2022 | know your way back: self training method of graph neural network under distribution and migration
Déchirure à la main - tri
SQL:常用的 SQL 命令
regular expression
Suggestions on settlement solution of u standard contract position explosion
手撕——排序
Target free or target specific: a simple and effective zero sample position detection comparative learning method
潘多拉 IOT 开发板学习(HAL 库)—— 实验2 蜂鸣器实验(学习笔记)
okcc为什么云呼叫中心比传统呼叫中心更好?
Monkey test
【leetcode】34. Find the first and last positions of elements in a sorted array
手撕——排序
10 minutes to understand CMS garbage collector in JVM
Installation and use of blue lake
[untitled]
The fourth provincial competition of Bluebridge cup single chip microcomputer
潘多拉 IOT 开发板学习(RT-Thread)—— 实验1 LED 闪烁实验(学习笔记)