Created
June 24, 2020 15:31
-
-
Save searover/3a541e71bca2b62736f328ce5519dcf8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class VolatileExample { | |
int x = 0; | |
volatile boolean v = false; | |
void writer() { | |
x = 42; | |
v = true; | |
} | |
void reader() { | |
if (v == true){ | |
System.out.println(x); // What exactly x is? | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment