解决方案 »

  1.   

    不会拷贝 直接从主内存中取,改的时候也是直接刷新到主内存。但是要注意,volatile依然不能完全确保线程安全,因为有些JVM指令不是单一操作,比如自增减。
      

  2.   

    准确的说应该是会拷贝(临时变量),只是修改会立即更新,获取会直接从主内存取
    不对把,我记得是会拷贝的。
    对于volatile修饰的变量,jvm虚拟机只是保证从主内存加载到线程工作内存的值是最新的,因此才会由volatile不能完全确保线程安全这样的问题。比如自增自减
      

  3.   

    对于volatile修饰的变量,jvm虚拟机只是保证从主内存加载到线程工作内存的值是最新的。正解
      

  4.   

    The volatile keyword is used as a modifier on member variables to force individual
    threads to reread the variable’s value from shared memory every time the variable is
    accessed. In addition, individual threads are forced to write changes back to shared
    memory as soon as they occur. This way, two different threads always see the same
    value for a member variable at any particular time.