volatile keyword is not everything to prevent compiler optimization

When you add the keyword “volatile” in front of variable declaration, it prevents compiler to optimize the line that are using that variable. But if the line is completely useless, compiler will still optimized it out, prevent to generate any byte code for it.

still-optimized-out-useless-line

Leave a Reply

Your email address will not be published. Required fields are marked *