当前位置:网站首页>Status of the thread
Status of the thread
2022-06-13 00:59:00 【-LM-】
State of thread
- The initial state (NEW): Thread created , But not yet called start() Method .
- Running state (RUNNABLE):Java The two states of ready and running are generally called running in the thread .
- Blocking (BLOCKED): Indicates that the thread is blocked by a lock .
- wait for (WAITING): A thread entering this state needs to wait for some specific action from another thread ( Notification or interruption ).
- Overtime waiting (TIMED_WAITING): This state is different from WAITING, It can return on its own after a specified time .
- End (TERMINATED): Indicates that the thread has finished executing .
Thread state transition diagram

Thread state details
1、 The initial state
Realization Runnable Interfaces and inheritance Thread You can get a thread class ,new An example comes out , The thread is in its initial state .
2、 Running state
Ready state :
- Ready state just means that you are qualified to run , The scheduler didn't pick you , You are always ready .
- Calling thread's start() Method , This thread is in ready state .
- Current thread sleep() Method end , Other threads join() end , Wait for user input to complete , A thread gets the object lock , These threads will also be ready .
- The current thread time slice is used up , Call the... Of the current thread yield() Method , The current thread is in ready state .
- After the thread in the lock pool gets the object lock , Get ready .
In-service state :
The thread scheduler selects a thread from the runable pool as the current thread's state . This is also the only way for a thread to enter a running state .
3、 Blocked state
The blocking state is that the thread is blocking into synchronized Keyword decorated method or code block ( Get the lock ) State of .
4、 Wait state
Threads in this state are not allocated CPU execution time , They wait to be awakened explicitly , Otherwise it will be in a state of waiting indefinitely .
5、 Timeout wait status
Threads in this state are not allocated CPU execution time , But there is no need to wait indefinitely for other threads to wake up , They wake up automatically after a certain time .
6、 Termination status
- Thread run() When the method is complete , Or the main thread 's main() When the method is complete , We think it's over . This thread object may be alive , But it's no longer a single thread of execution . Once the thread is terminated , Can't be reborn .
- Called on a terminated thread start() Method , Will throw out java.lang.IllegalThreadStateException abnormal .
边栏推荐
- 什么是 Meebits?一个简短的解释
- Three column simple Typecho theme lanstar/ Blue Star Typecho theme
- spiral matrix visit Search a 2D Matrix
- 什么是 dummy change?
- Aunt learning code sequel: ability to sling a large number of programmers
- Win10 home vs pro vs enterprise vs enterprise LTSC
- Binary tree -- using hierarchical sequence and middle sequence to determine a tree
- Matrix fast power
- Canvas game lower level 100
- Andersen Global通过在芬兰和丹麦的合作协议拓展北欧地区业务版图
猜你喜欢

Triangle wave and triangle wave convolution

spiral matrix visit Search a 2D Matrix

408 true question - division sequence

Mysql database password modification

MySQL exception: com mysql. jdbc. PacketTooBigException: Packet for query is too large(4223215 > 4194304)

Introduction to ROS from introduction to mastery (zero) tutorial

Most elements leetcode

什么是 dummy change?

People and gods are angry. Details of Tangshan "mass beating of women incident"

Hard (magnetic) disk (II)
随机推荐
Traditional machine learning classification model predicts the rise and fall of stock prices
How to choose stocks? Which indicator strategy is reliable? Quantitative analysis and comparison of strategic benefits of ASI, VR, arbr, DPO and trix indicators
切线与切平面
Kotlin 协程的作用域构建器 coroutineScope与runBlocking 与supervisorScope,协程同步运行,协程挂掉的时候其他协程如何不被挂掉。
Common skills for quantitative investment - indicators Chapter 3: detailed explanation of RSI indicators, their code implementation and drawing
gpu加速pytorch能用吗?
How to solve the duplication problem when MySQL inserts data in batches?
Unity calls alertdialog
[server data recovery] successful cases of data loss recovery during data migration between storage servers
. The way to prove the effect of throwing exceptions on performance in. Net core
Illustrator tutorial, how to add dashes and arrows in illustrator?
Undirected graph -- computing the degree of a node in compressed storage
Hard (magnetic) disk (I)
Wal mechanism of MySQL
The grass is bearing seeds
Google play console crash information collection
Canvas random bubbling background
Sequence table - find main element
Biological unlocking - Fingerprint entry process
Breadth first search for node editor runtime traversal