当前位置:网站首页>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
边栏推荐
- 如何解决在editor模式下 无法删除物体的问题
- 【人员密度检测】基于形态学处理和GRNN网络的人员密度检测matlab仿真
- Qt插件之Qt Designer插件实现
- [personnel density detection] matlab simulation of personnel density detection based on morphological processing and GRNN network
- 藍湖的安裝及使用
- How to model noise data? Hong Kong Baptist University's latest review paper on "label noise representation learning" comprehensively expounds the data, objective function and optimization strategy of
- go 分支与循环
- Lost a few hairs, and finally learned - graph traversal -dfs and BFS
- The 8th Blue Bridge Cup single chip microcomputer provincial competition
- 云服务器的安全设置常识
猜你喜欢
整理了一份ECS夏日省钱秘籍,这次@老用户快来领走
The second game of the 12th provincial single chip microcomputer competition of the Blue Bridge Cup
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
Suggestions on settlement solution of u standard contract position explosion
WPViewPDF Delphi 和 .NET 的 PDF 查看组件
树莓派GPIO引脚控制红绿灯与轰鸣器
Installation et utilisation du lac bleu
【直播回顾】战码先锋首期8节直播完美落幕,下期敬请期待!
MySQL advanced SQL statement 2
WiFi 5GHz frequency
随机推荐
【小技巧】使用matlab GUI以对话框模式读取文件
Go function
The 10th Blue Bridge Cup single chip microcomputer provincial competition
【无线图传】基于FPGA的简易无线图像传输系统verilog开发,matlab辅助验证
[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)
LxC limits the number of CPUs
[personnel density detection] matlab simulation of personnel density detection based on morphological processing and GRNN network
一文彻底理解评分卡开发中——Y的确定(Vintage分析、滚动率分析等)
First acquaintance with string+ simple usage (II)
Wechat applet map annotation
WPViewPDF Delphi 和 .NET 的 PDF 查看组件
go 语言命名规范
The 6th Blue Bridge Cup single chip microcomputer provincial competition
C language: examples of logical operation and judgment selection structure
【c语言】基础篇学习笔记
[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)
cookie、session、tooken
Wpviewpdf Delphi and Net PDF viewing component
手撕——排序
[untitled]