125

volatile变量与普通变量的区别

 6 years ago
source link: https://juejin.im/post/59cf5bedf265da06710dd337
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
我们通常会用volatile实现一些需要线程安全的代码(也有很多人不敢用,因为不了解),但事实上volatile本身并不是线程安全的,相对于synchoronized,它有更多的使用局限性,只能限制在某些特定的场景。本篇文章的目的就是让大家对 volatile

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK