Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to draw java Thread State Diagram

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to draw java thread state diagram". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to draw a Java thread state diagram.

Graphic description

Before I started writing this article, I searched the Internet for a lot of diagrams about thread state transitions, and I was surprised to find that more than 80% of the diagrams were incomplete or wrong. So I have to read the source code again, and then draw the following picture, understand this diagram, for you to understand the java thread method calls and development process will be of great help.

The synchronous blocking state is easier to understand, that is, mutexes, the code blocks used by the current thread can only be used by you when I run out of them.

The main difference between delayed waiting state and waiting state is that

The delayed wait state does not release any resources and monitors. Even if I don't shit in the manger, I won't give it to you. I'm just taking a break. I've finished my rest, and mine is still mine.

Waiting for blocking state will temporarily release relevant thread resources and monitors. My resources will be lent to you for the time being, and you will give them back to me when I notify calls you.

Thread.State source code comment public enum State {/ * newborn status: thread object is created, but not yet start () * / NEW, / * thread is runnable, but this runnable state does not mean that the thread must be executed in the virtual machine. * you need to wait for resources (such as processor time slices) to be obtained from the operating system before you can actually run * / RUNNABLE. / * the current thread is blocked and is waiting for the monitor lock release of another thread. To enter the synchronized code block or method * / BLOCKED, / * the current thread is waiting after calling the Object#wait () and Thread.join methods, * waiting for other threads to perform specific actions before exiting from the waiting state. * for example, the thread of Object.wait () needs to wait for other threads to call Object.notify () and Object.notifyAll () to exit * for example, the thread that called Thread.join () needs to wait for the specified thread to finish execution before exiting the waiting state. * / WAITING, / * enter the waiting state for a specified period of time, waiting for a specified period of time sleep (timed), wait (timed) or Thread.join (timed). * automatically exit and return to RUNNABLE state * / TIMED_WAITING, / * * thread end state * / TERMINATED;} at the specified time. I believe you have a better understanding of "how to draw Java thread state diagram". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report