This flag allows the JVM to disable background compilation and block threads until the compilation is finished.
Starting from JDK 6.
This will instruct JVM to disable background compilation:
java -XX:-BackgroundCompilation MainClass
Just In Time Compiler (JIT), generally translated as a real-time compiler, this is for interpreted languages, and is not necessary for virtual machines, it is an optimization method, The Java virtual machine standard does not make any specification for the existence of JIT, so this is a custom optimization technique implemented by the virtual machine.
JVM can execute Java code in two ways: [interpretation and execution] and [compile and execute]. If the execution method is compiled and executed, JIT will be used, but interpretation and execution will not be used. JIT, therefore, in the early days, there is no problem to say that Java is an interpreted language, but in the Java virtual machine environment with JIT, it is strictly incorrect to say that Java is an interpreted language.
The compiler in JVM is javac, and his job is to compile the source code into bytecode. This part of the work is completely independent and does not require runtime participation at all, so the compilation of Java programs is a semi-independent implementation. With the bytecode, there is an interpreter for interpretation and execution. This is the workflow of the early virtual machine. Later, the virtual machine will compile the method or statement block with high execution frequency into local machine code through JIT, which improves the execution time of the code.
By default, the JVM is executed in the interpreted mode before the compilation is completed for the instant compilation request, and the compilation action is performed in the background thread.
The parameter “-XX:-BackgroundCompilation” disables background compilation. At this time, the compilation request will wait until the local code is executed directly after the compilation is completed.
By default, this flag is enabled.
Edit your Comment