Skip to content

Instantly share code, notes, and snippets.

@jskeet
Created January 31, 2019 17:05
Show Gist options
  • Save jskeet/9211f9831c9923a7e83ab6fbc8cd41a6 to your computer and use it in GitHub Desktop.
Save jskeet/9211f9831c9923a7e83ab6fbc8cd41a6 to your computer and use it in GitHub Desktop.
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