The JVM executes the native method, the counter is empty (undefined), and how does the Java code continue to execute the problem?

Source: Internet
Author: User

In the automatic memory allocation of Java, we see a sentence:

If the thread is executing a Java method, this counter records the address of the virtual machine bytecode instruction being executed, and if the native method is being executed, the counter value is empty (undefined);

Problem:

We know that the program counter is used to hold the byte code instruction address, through this address, the virtual machine can know where to execute, and how to execute, can call the native method, the value becomes empty, then the machine does not directly crash?

Explain:

The reference to C + + understanding is that when a thread calls the native method, it restarts a new thread , and the new thread's counter is empty without affecting the current thread's counters, independent of each other.

Problem:

If it is a newly started thread, will it not be possible to control the order of execution because of the thread async problem?

Explain:

The current thread should be blocked , knowing that another thread has finished executing. For example: To control congestion through a dead loop (of course the dead cycle is too inefficient, here is just an example)

The JVM executes the native method, the counter is empty (undefined), and how does the Java code continue to execute the problem?

Related Article

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.