Sychronized & Volatile

Synchronized 保证了可见性 ,并且保证了原子性
Volatile只保证了可见性,不能保证原子性,即只能保证读的过程的准确性,但是不能保证写的过程的准确性。

你可能感兴趣的:(Sychronized & Volatile)