Created
January 31, 2019 17:05
-
-
Save jskeet/9211f9831c9923a7e83ab6fbc8cd41a6 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
using System; | |
using System.Threading; | |
class Program | |
{ | |
static int value; | |
static void Main(string[] args) | |
{ | |
new Thread(ChangeValueRepeatedly).Start(); | |
ShowRepeatedly(in value); | |
} | |
static void ChangeValueRepeatedly() | |
{ | |
Random random = new Random(); | |
for (int i = 0; i < 100; i++) | |
{ | |
value = random.Next(); | |
Thread.Sleep(1000); | |
} | |
} | |
static void ShowRepeatedly(in int x) | |
{ | |
for (int i = 0; i < 100; i++) | |
{ | |
Console.WriteLine(x); | |
Thread.Sleep(1000); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment