A note on the volatile keyword

The Volatile keyword only has visibility and does not have synchronization (atomicity). It is a lightweight synchronized. Its performance is much stronger than that of synchronized, and it will not cause blocking. If you want to ensure the atomicity of data, you can use the atomic class to ensure itself. The atomicity of methods, but atomic does not guarantee the atomicity of multiple operations

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324682269&siteId=291194637