volatile Variables : volatile « Modifiers « SCJP






The volatile modifier applies only to instance variables.

The volatile modifier tells the JVM that a thread accessing the variable must always reconcile 
its own private copy of the variable with the master copy in memory. 

The volatile variables might be modified asynchronously

public class MainClass{
    volatile int i=0;
    
    public static void main(String[] argv){
      System.out.println();
    }
}








3.13.volatile
3.13.1.volatile Variables