2: Java Virtual Machine Overview

Source: Internet
Author: User
Java Virtual Machine Definition

Java virtual machines are called "virtual" because they are just abstract computers defined by a specification.

 

What is a Java Virtual Machine?
      1. Abstract Specification
      2. A specific implementation based on abstract specifications
      3. A running Virtual Machine instance

Java Virtual Machine abstract specification is just a concept. Generally speaking, Java virtual machines are specific implementations of this specification. This implementation may come from multiple providers and coexist on multiple platforms. It can be fully implemented by software, or by combining hardware and software. When a JavaProgramAt the same time, a Java Virtual Machine instance is running.

Java Virtual Machine (JVM) is an imaginary machine that is simulated by software. Java virtual machines have their own hardware, such as processors, stacks, registers (simulated by java stack), and corresponding command systems.

The Java Virtual Machine acts as a hardware platform. If it is equivalent to a real hardware system, the Java language is equivalentC LanguageThe compiled class bytecode file in Java is equivalent to the Assembly command for this hardware platform.

Lifecycle of a Java Virtual Machine

1: A running Java VM instance is responsible for running a Java program. When a Java program is started, a virtual machine instance is born. When the program is closed and exited, the virtual machine instance will die. If you run three Java programs on one computer at the same time, you will get three Java Virtual Machine instances. Each Java program runs in its own Java Virtual Machine instance

2: There are two threads in the Java Virtual Machine: the daemon thread and the non-daemon thread. Daemon threads are generally used by virtual machines, such as threads that execute garbage collection tasks. However, a Java program can mark any thread it creates as a daemon thread. The main thread of the main () method of the initial thread in the Java program is a non-daemon thread. As long as there are any non-daemon threads running, the Java program continues to run. When all the non-daemon threads in the program are terminated, the VM instance automatically exits. If the security manager permits, the program itself can exit by calling the exit () method of the runtime class or system class.

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.