The last: 024 – the JVM – custom class loader https://yuhongliang.blog.csdn.net/article/details/111567879 hotspot what meaning, is the meaning of hot spot detection, jit is, When the hotspot is detected, it is compiled into native code and then executed quickly.

1. What is hot code

The code that executes more tests can be set with parameters:

-xx :CompileThreshold = 10000 The default value is 10000Copy the code

Times greater than this trigger just-in-time compilation!

2. What is the default execution mode?

Mixed mode:

3. Switching between the modes and practice comparison

3.1 Test Code

package com.yuhl.c2020;

/ * * *@author yuhl
 * @Date2020/12/23 * mark@Classname JIT
 * @DescriptionInterpret execution and compile execution */
public class JIT {
    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        /** * hybrid: 4746ms **

        for(int i=0; i<10 _0000; i++) {
            m();
        }

        long end = System.currentTimeMillis();

        System.out.println(end - start);
    }

    public static void m(a) {
        for(long i=0; i<10_0000L; i++) {
            long j = i%3; }}}Copy the code

The JVM execution mode can be modified before execution:

  1. In the current test case there is no mixed mode and jit mode is not much different.
  2. Hybrid modes are most efficient in production environments
  3. Pure explanation is not desirable, too slow. Especially in the case of repeated execution of the same method there are many cases.
  4. Pure JIT is also not desirable, it may take a lot of time at startup time, if you do not consider the startup time can use this method. Next article: 026 – the JVM – the JVM delay loading https://yuhongliang.blog.csdn.net/article/details/111600183 for class