Created
November 19, 2017 19:07
-
-
Save luisdeol/308818e5be0fee7948a071d51c991885 to your computer and use it in GitHub Desktop.
Example of a situation where Volatile can be used.
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
private static int _theFlag; | |
private static int _theValue; | |
public static void TheFirstThread() | |
{ | |
_theValue = 10; | |
_theFlag = 1; | |
} | |
public static void TheSecondThread() | |
{ | |
if (_theFlag == 1) | |
Console.WriteLine(_theValue); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment