当前位置:网站首页>Six states of threads

Six states of threads

2022-06-24 10:23:00 Ugly and ugly

stay Java in , Threads have the following six states :

state explain
NEW The initial state : Thread created , But it's not called yet start() Method
RUNNABLE Running state :Java Threads refer to the ready and running states of the operating system as “ Running state ”
BLOCKED Blocked state : Indicates that the thread is blocked by a lock
WAITING Wait state : Indicates that the thread is waiting , Entering this state means that the current thread needs to wait for other threads to make some specific actions ( Notification or interruption )
TIME_WAITING Timeout wait status : This state is different from WAITIND, It can return by itself at a specified time
TERMINATED Termination status : Indicates that the current thread has finished executing

Threads are in their own life cycle , It's not fixed in a certain state , It's switching between different states as the code executes ,Java The following figure shows the change of thread status :

 

This article references from : Face slag counter attack :Java Ask , Let's see how many ways you can ! - Nuggets

原网站

版权声明
本文为[Ugly and ugly]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206240916245607.html