Java Thread State and transformation

Source: Internet
Author: User

There are 6 states of Java threads:

Create new thread new, start thread runnable, block block, wait timed_waiting, wait for thread waiting, terminate thread terminated

1. Time-limited Wait timed waiting: Threads in this state are not allocated CPU execution times. However, there is no need to wait for the other lines to wake up Cheng, after a certain period of time they will be automatically awakened by the system. The following method causes the thread to wait for a time-limited time:

A. Thread.Sleep () method;

B. Set the Object.wait () method of the timeout parameter;

C. Set the Thread.Join () method of the timeout parameter;

D. Locksupport.parnanos () method;

E. Locksupport.parkuntil () method.

2. Wait indefinitely waiting: threads in this state are not allocated CPU execution time. They wait to be awakened by other threads Cheng.

The following method causes the thread to enter an indefinite wait state:

A. The Object.wait () method is not set for the timeout parameter.

B. The Thread.Join () method is not set for the timeout parameter.

C. Locksupport.park () method.

3. Blocking Blocked: The thread is blocked. The difference between "blocking state" and "waiting state" is that the "blocking state" is waiting for an exclusive lock, and this event will occur when another thread discards the lock. The "Waiting state" is the time to wait, or the wake-up action to occur. While the program is waiting to enter the synchronization area,
The thread will enter this state.

The transformation of the thread state is as follows:

Reference: "In-depth understanding of Java virtual machines"

Java Thread State and transformation

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.