Java memory Area--in-depth understanding of Java Virtual Machine Learning notes (i)

Source: Internet
Author: User
Tags switches
Program Counter Program counter What do you do?

With it, the bytecode interpreter can know which of the next bytecode instructions to execute.

This program counter is required either to remove an instruction or branch, loop, jump, interrupt, or thread recovery.

Where does the program counter exist?

The virtual machine differs from the hardware, and the program counter of the composition principle is stored with CS and IP register to represent the instruction address.

Java has the program counter in memory.

Do I seem to have heard of the program counter in the operating system?

is a bit similar to the program counters in the operating system.

At one point, a processor executes only one thread, and the hotspot uses the native threading model, the OS thread, and the Java thread 1:1 mapping.

In the operating system, when multiple threads switch execution, each thread needs to record where it was interrupted so that it can continue to execute after the thread is resumed.

Referring to the thread control block (TCB) in the operating system, when the thread switches to save the context state, including the instruction counter PC, the thread is interrupted and then switched back to know where to start to continue execution.

In Java, too, when multiple threads are executing, they are also rotated between threads, and when a thread switches back, it needs a program counter to indicate where to start execution for that thread.

So it's good to understand that Java's program counters are ' thread-private ' and each thread has one.

I heard that the program counter can also be empty?

When Java executes the native method, it does not work in Java, but instead calls the methods in the operating system, so the Java program counter is not needed at this time, and is empty.

Since the program counter is empty at this time, when the native method is finished, where should it go?

http://ms.csdn.net/geek/187200

Not to be continued.

Java memory Area--in-depth understanding of Java Virtual Machine Learning notes (i)

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.