当前位置:网站首页>What states do threads have?
What states do threads have?
2022-06-12 06:09:00 【Z boo boo】
The state of the thread is in Java The level is slightly different from the level of the operating system , The following from Java And operating system
Java Threads are divided into six states
- NEW New state
The newly created thread has not been associated with the underlying thread of the operating system , It can only be said that it was just new Out object
- RUNNABLE Operational state
Runnable state means that the thread in the new state calls start After method , It enters the operational state , Only runnable threads are associated with the underlying threads of the operating system
- TERMINATED Termination status
When the code executed by the thread is finished , Enter this end state
- BLOCKED Blocked state
A blocking state is when multiple threads access a shared resource , Access to resources is obtained by obtaining locks , When the lock acquisition fails, it will enter the blocking state , Of course, threads in a blocked state can still compete for locks , When it acquires the lock, it changes from the blocking state to the operable state
- WAITING Wait state
The waiting state is like this , When the thread acquires the lock successfully , However, it cannot be continued for some reasons , It will be called by wait Method then enters the waiting state , A thread in a waiting state , call notify Method to return from the waiting state to the runnable state
- TIMED_WAITING Time limited waiting state
The principle of time limited waiting state is similar to that of waiting state , It just adds a waiting implementation , The original normal wait state is only called notify Method before returning to the runnable state , But the time limited waiting state , If you are not awakened after the time has expired, you will automatically wake up and return to the operable state
Entering a time limited wait state, you can call the with parameters wait(long) Method , And you can call sleep(long) Method
- Java Level thread state transition diagram

The operating system level is divided into five states
- The operating system level will Java The operational state of the layer is split into two states , One is ready , One is running status
- take Java Blocking in , wait for , Time limited waiting is called blocking state
- New state
Threads have just been created , Has not been assigned to CPU The ability of time slice
- Ready state
New thread calls start After the method , The state the thread enters , At this point, the thread has the ability to rob cpu The ability of time slice
- Running state
When a thread is assigned to cpu Time slice time , It goes into operation , Execute the relevant code
- Blocked state
The thread encounters some blocking time during execution
- Termination status
The thread task will enter this termination state after execution
- Operating system level thread state transition diagram

边栏推荐
- A month's worth of DDD will help you master it
- Directx11 advanced tutorial tiled based deffered shading
- Unity C script implements AES encryption and decryption
- Leetcode-1512. Number of good pairs
- Logistic regression model
- Leetcode-1260. 2D mesh migration
- Leetcode sword finger offer II 033 Modified phrase
- E-book analysis
- User login [next]
- How to split a row of data into multiple rows in Informix database
猜你喜欢
随机推荐
Sqlite Cross - compile Dynamic Library
Brief introduction to project development process
Une explication du 80e match bihebdomadaire de leetcode
Cross compile libev
Nrf52832 services et fonctionnalités personnalisés
English grammar_ Adverb_ With or without ly, the meaning is different
Summary of some problems in sensor bring up
Leetcode-1706. Where does the club fall
Nrf52832 -- official routine ble_ app_ UART adds the LED feature to enable the computer UART and mobile app to control the LED on and off of the development board
Pytorch implementation of regression model
夜神模擬器adb查看log
Leetcode-2048. Next larger numerical balance
In unity3d, billboard effect can be realized towards another target
nRF52832自定義服務與特性
Redis队列
Json-c common APIs
Cause analysis of motion blur / smear caused by camera shooting moving objects
Why doesn't the database use binary tree, red black tree, B tree and hash table? Instead, a b+ tree is used
Automatic annotation of target detection based on lffd model to generate XML file
夜神模拟器adb查看log









