当前位置:网站首页>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
边栏推荐
- Go language introduction
- 蓝湖的安装及使用
- QT designer plug-in implementation of QT plug-in
- Pandora IOT development board learning (HAL Library) - Experiment 2 buzzer experiment (learning notes)
- 整理了一份ECS夏日省钱秘籍,这次@老用户快来领走
- Blue Bridge Cup single chip microcomputer sixth temperature recorder
- [ibdfe] matlab simulation of frequency domain equalization based on ibdfe
- Today's plan: February 15, 2022
- 5G時代全面到來,淺談移動通信的前世今生
- Go语言介绍
猜你喜欢

Li Kou interview question 02.08 Loop detection

Finally got byte offer. The 25-year-old inexperienced perception of software testing is written to you who are still confused

WiFi 5GHz frequency

The 5th Blue Bridge Cup single chip microcomputer provincial competition

The first game of the 11th provincial single chip microcomputer competition of the Blue Bridge Cup

Hands on deep learning (II) -- multi layer perceptron

Sword finger offer II 006 Sort the sum of two numbers in the array

毕设-基于SSM电影院购票系统

树莓派GPIO引脚控制红绿灯与轰鸣器

u本位合约爆仓清算解决方案建议
随机推荐
Is the product of cancer prevention medical insurance safe?
Three ways for programmers to learn PHP easily and put chaos out of order
蓝湖的安装及使用
The 6th Blue Bridge Cup single chip microcomputer provincial competition
软件测试人的第一个实战项目:web端(视频教程+文档+用例库)
Pandora IOT development board learning (RT thread) - Experiment 1 LED flashing experiment (learning notes)
毕设-基于SSM电影院购票系统
JVM知识点
The first practical project of software tester: web side (video tutorial + document + use case library)
手撕——排序
Introduction to JSON usage scenarios and precautions
Spring recruitment of Internet enterprises: Kwai meituan has expanded the most, and the annual salary of technical posts is up to nearly 400000
How much is the tuition fee of SCM training class? How long is the study time?
66.qt quick-qml自定义日历组件(支持竖屏和横屏)
[ibdfe] matlab simulation of frequency domain equalization based on ibdfe
Lei Jun wrote a blog when he was a programmer. It's awesome
How to solve the problem that objects cannot be deleted in Editor Mode
【leetcode】34. Find the first and last positions of elements in a sorted array
【c语言】基础篇学习笔记
Go branch and loop