Also say Java Virtual machine

Source: Internet
Author: User

people who learn Java do not know the Java virtual machine, it is really white learning. Why Java can cross-platform, because of the role of virtual machines, Java Virtual machine is the equivalent of a computer, it has its own memory structure, when the Java program is running on the computer, is actually running on the virtual machine; Java programs can be run when a Java virtual machine is installed on any system computer;Let's take a look at the memory model of the Java Virtual machine (on-line search):method Area: When the Java program is loaded, the class, member variables, static variables and other information are saved to the method area;constant pool: a constant pool is a part of a method area that holds constant information created during program execution;heap: Used to save the Java program in the new (Java keyword) out of the object, the main area of the GC;Java Virtual machine stack: Where Java programs are run, we know that Java programs are actually executed in one way or the other. Starting with the main method, you might call n multiple methods, and each time you execute a method,A frame is created to hold the method parameters, local variables, method exits and other information; When the method executes, the frame POPs back to the previous frame (the execution of each method corresponds to a frame in the virtualThe process of the stack's entry and exit) until the main method executes;Program counter: is also a piece of memory space. Java compiles the Java program into bytecode and translates it into native code for computer recognition, and the program counter is used to point to the bytes executed by the current thread .code line number, as in the single-step debug program, each step, the indicator will point to the line number that is running, the program counter is similar function, in the virtual machine model, the bytecode interpreter is based on the programcounter to select the next command to execute, the normal execution of the program is identified by it, when the thread is not executing a Java method, the value of the program counter is empty;Local method stack: Similar to Java virtual stack, but Java virtual stack is to execute Java program, and the local method stack is to execute Java native method;because Java program can run multithreaded, so, Java virtual stack, the local method stack, program counters are thread-private, each thread has its own Java virtual stack and program counters to ensure that the line Shuofull operation;method areas and heaps are thread-shared, all-thread-common method areas and heaps (so threads are safe and non-thread safe to say)

Also say Java Virtual machine

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.