Java Threading: Line stacks Model

Source: Internet
Author: User

To understand the principle of thread scheduling and the thread execution process, you must understand the line stacks model.

Line stacks refers to the stack information of the memory thread dispatching at a certain time, the method that is currently called is always at the top of the stack. The content of the line stacks is dynamically changing as the program runs, so the research thread stack must choose a running moment (actually where the code is running).

Next, let's say the process of stacks with this code and picture

Package cn.happy.bdqn; Public classtestrunnable {/** * @param args*/     Public Static voidMain (string[] args) {//TODO auto-generated Method StubSystem. out. println ("Hello world!"); Newtestrunnable (); }     Public voidMeThod () {dosomething DS1=NewDoSomething ("three o"); Thread T1=NewThread (DS1);            T1.start (); }}

As you can see, when the code executes to two moments (1 and 2), the virtual machine calls the stack process.

When the program executes to T1.start (), it can be seen that the program has one more branch, (add a call stack B), so stack A and stack B are executed in parallel.

Java Threading: Line stacks Model

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.