当前位置:网站首页>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
边栏推荐
- Introduction to JSON usage scenarios and precautions
- Bitmap principle code record
- Which insurance company has a better product of anti-cancer insurance?
- Li Kou interview question 02.08 Loop detection
- [ibdfe] matlab simulation of frequency domain equalization based on ibdfe
- Hands on deep learning (II) -- multi layer perceptron
- "No war on the Western Front" we just began to love life, but we had to shoot at everything
- [untitled]
- 【leetcode】34. Find the first and last positions of elements in a sorted array
- A thorough understanding of the development of scorecards - the determination of Y (Vintage analysis, rolling rate analysis, etc.)
猜你喜欢
Introduction to vmware workstation and vSphere
手撕——排序
How should the team choose the feature branch development mode or trunk development mode?
The fourth provincial competition of Bluebridge cup single chip microcomputer
The confusion I encountered when learning stm32
藍湖的安裝及使用
The 6th Blue Bridge Cup single chip microcomputer provincial competition
Sword finger offer II 006 Sort the sum of two numbers in the array
Fluent icon demo
Www 2022 | rethinking the knowledge map completion of graph convolution network
随机推荐
蓝湖的安装及使用
okcc为什么云呼叫中心比传统呼叫中心更好?
Go语言介绍
向数据库中存入数组数据,代码出错怎么解决
[ibdfe] matlab simulation of frequency domain equalization based on ibdfe
【人员密度检测】基于形态学处理和GRNN网络的人员密度检测matlab仿真
手撕——排序
66.qt quick-qml自定义日历组件(支持竖屏和横屏)
SQL:常用的 SQL 命令
The original author is out! Faker. JS has been controlled by the community..
集成底座方案演示说明
Vite: configure IP access
Three ways for programmers to learn PHP easily and put chaos out of order
【力扣刷题】15.三数之和(双指针);17.电话号码的字母组合(递归回溯)
A thorough understanding of the development of scorecards - the determination of Y (Vintage analysis, rolling rate analysis, etc.)
LxC limits the number of CPUs
The 6th Blue Bridge Cup single chip microcomputer provincial competition
Wechat applet pull-down loading more waterfall flow loading
Pandora IOT development board learning (RT thread) - Experiment 1 LED flashing experiment (learning notes)
【直播回顾】战码先锋首期8节直播完美落幕,下期敬请期待!