[Solved] How to avoid using volatile in Java
I have to use volatile to guarantee the value is always read from main memory That is not how volatile work. volatile is used to build a happens-before relation ship: This means that changes to a volatile variable are always visible to other threads. What’s more, it also means that when a thread reads a … Read more