Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the states of threads in Java

Shulou Source: shulou.com Published: 2022-06-03 05:06:26 10月13日 Update

Java thread in several states is what, many novices are not very clear about this, in order to help you solve this problem, the following small series will explain in detail for everyone, there are people who need to learn, I hope you can harvest.

Threads in Java have the following states:

New status: newly created thread, not yet executed.

Runnable: Executed the start() method, waiting to run,

Running: A thread in a ready state begins executing program code.

Blocked (Blocked)

Synchronous blocking: During operation, you need to get the lock to run, and the lock is occupied by other resources and needs to wait. Waiting for congestion: The wait() method was executed, and the wait was entered. Other jams: join(), sleep() methods executed and waiting entered.

Terminated: End after running the run() method, or terminate due to an exception.

New: Newly created thread, not yet executed; Runnable: running thread, executing Java code for the run() method; Blocked: running thread, pending because some operation is blocked; Waiting: running thread, pending because some operation is waiting; Timed Waiting: running thread, waiting because execution of the sleep() method is timed; Terminated: thread terminated because run() method has finished executing.

Did reading the above help you? If you still want to have further understanding of related knowledge or read more related articles, please pay attention to the industry information channel, thank you for your support.

Tags: Thread run state method code in progress help block clear content not yet article novice more knowledge program industry resources information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Microsoft MySQL macOS Docker