Created
March 23, 2016 21:16
-
-
Save m0wfo/3f662bebc4db5afe8a38 to your computer and use it in GitHub Desktop.
VolatileExample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class VolatileClass implements Runnable { | |
public volatile long a; | |
@Override | |
public void run() { | |
long b; | |
for (int i = 0; i < 1E9; i++) { | |
b = a; | |
} | |
System.out.println(a); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment