当前位置:网站首页>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
边栏推荐
- SQL:常用的 SQL 命令
- 《动手学深度学习》(二)-- 多层感知机
- QT designer plug-in implementation of QT plug-in
- 【小技巧】使用matlab GUI以对话框模式读取文件
- Go language naming specification
- 《西线无战事》我们才刚开始热爱生活,却不得不对一切开炮
- 【leetcode】74. Search 2D matrix
- The 6th Blue Bridge Cup single chip microcomputer provincial competition
- Blue Bridge Cup single chip microcomputer sixth temperature recorder
- The first game of the 12th Blue Bridge Cup single chip microcomputer provincial competition
猜你喜欢

【人员密度检测】基于形态学处理和GRNN网络的人员密度检测matlab仿真

Yyds dry inventory compiler and compiler tools

Installation and use of blue lake

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

一文彻底理解评分卡开发中——Y的确定(Vintage分析、滚动率分析等)

The fourth provincial competition of Bluebridge cup single chip microcomputer

手撕——排序

2022-07-01: at the annual meeting of a company, everyone is going to play a game of giving bonuses. There are a total of N employees. Each employee has construction points and trouble points. They nee

WPViewPDF Delphi 和 .NET 的 PDF 查看组件

Introduction to vmware workstation and vSphere
随机推荐
Monkey test
Déchirure à la main - tri
First acquaintance with P4 language
The confusion I encountered when learning stm32
Wechat applet map annotation
【小技巧】使用matlab GUI以对话框模式读取文件
SQL: common SQL commands
Typescript practice for SAP ui5
SQL Yiwen get window function
Where can I buy cancer insurance? Which product is better?
如何解决在editor模式下 无法删除物体的问题
Nacos 配置中心整体设计原理分析(持久化,集群,信息同步)
《西线无战事》我们才刚开始热爱生活,却不得不对一切开炮
Cloud service selection of enterprises: comparative analysis of SaaS, PAAS and IAAs
Www 2022 | rethinking the knowledge map completion of graph convolution network
Finally got byte offer. The 25-year-old inexperienced perception of software testing is written to you who are still confused
整理了一份ECS夏日省钱秘籍,这次@老用户快来领走
毕设-基于SSM电影院购票系统
Jetpack之LiveData扩展MediatorLiveData
手撕——排序