AdoptOpenJDK / jitwatch

Log analyser / visualiser for Java HotSpot JIT compiler. Inspect inlining decisions, hot methods, bytecode, and assembly. View results in the JavaFX user interface.
Other
3.06k stars 437 forks source link

I restarted a thread in the main method, what should I do to see the machine code in the thread #334

Closed guangmingdexin closed 3 years ago

guangmingdexin commented 3 years ago
private static boolean run = true;

public static void main(String[] args) {

    Thread t = new Thread(() -> {
        int a = 5;
        while (run) {
            a = 1;
        }
        System.out.println("forever here!");
    });
    t.start();
    Sleep.sleep(1);
    run = false; 
}
chriswhocodes commented 3 years ago

Hi @guangmingdexin are you sure this code runs for long enough to trigger JIT compilation?

If you run it in the JITWatch sandbox mode then you will see a file called sandbox.log generated which contains all the JIT compiler decisions. You can paste that here if you like.

Cheers,

Chris

guangmingdexin commented 3 years ago

Thanks, I will test.