Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does JVM execute byte codes out-of-order?

Tags:

java

jvm

Some discussion threads have mentioned about out-of-order execution of Java code, however they do not explictly claim that JVM executes byte codes out-of-order. So I wonder if it is true; and if it is, is there an (official) technical document about the topic?

thanks.

Edit: I understand that CPU executes instructions out-of-order, but I wish to know whether JVM itself executes byte codes out-of-order.


1 Answers

JVMS explains this topic. In general, JVM is free to do some sort of reordering of the bytecode, which may produce unexpected behavior in multithreaded applications.

For single-threaded application and every single thread the reordering does not affect the behavior and program/thread execution is same as you expect in source code.

like image 164
jdevelop Avatar answered Nov 19 '25 11:11

jdevelop



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!