Java-17.3 thread status

Source: Internet
Author: User

Java-17.3 thread status

In this section, we will discuss the thread status.

1. Status

(1) New State (New): A New thread object is created.

(2) ready state (Runnable): After the thread object is created, other threads call the start () method of the object. The thread in this status is located in the runable thread pool and becomes runable, waiting to obtain the CPU usage right.

(3) Blocked: when a task wants to obtain the object lock, but the lock is held by another task, the status of the task is Blocked; when the Lock Object is held to release the lock, the task then holds the lock, and the task is not blocked.

(4) Waiting status (Waiting): When the thread waits for other threads to notify the scheduler to wake up for execution. This State occurs when methods such as Object. wait and Thread. join are executed.

(5) Time Waiting: the enhanced edition of the Waiting state, which increases the Waiting Time. When the timeout or notification is received, the thread will wake up and execute.

(6) Terminate: the thread has finished running or exited the run () method due to an exception.

2. Notes

The blocking status is different from the waiting status.

The blocking condition is related to the lock hold.

The waiting status is not necessarily related to the lock hold. It is related to some execution methods.

3. status chart

Summary: This chapter mainly discusses the thread status.

This chapter is here. Thank you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.