简体   繁体   中英

How do I avoid jvm running compiler threads in the jvm container

How do I avoid jvm running compiler threads in the jvm container.

"C1 CompilerThread1" #6 daemon prio=9 os_prio=0 tid=0x00007fb2980cc000 nid=0x440e waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" #5 daemon prio=9 os_prio=0 tid=0x00007fb2980be800 nid=0x440d waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

Those threads are from the hotspot compiler. If you want to get rid of them in the thread dump, start your application as java -Xint ... .

Be warned it might run slowly afterwards. ;-)

edit To make it clear. Disabling the JIT compiler is not something you want to do. As then the bytecode is executed in interpreted mode instead of compiled code for your plattform . see java options

small snippet for demonstration

public class Jit {
    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 10_000_000; i++) {
            sb.append(' ');
        }
        long end = System.currentTimeMillis();
        System.out.println("length = " + sb.length());
        System.out.println("duration: " + (end - start));
    }
}

run in mixed mode (compile on demand)

java Jit
length = 10000000
duration: 124

run in interpreted mode

java -Xint Jit
length = 10000000
duration: 3495

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM