Skip to content

Instantly share code, notes, and snippets.

@yutopio
Last active September 23, 2016 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yutopio/e0fa3aa93f0f3a245ec391e341346182 to your computer and use it in GitHub Desktop.
Save yutopio/e0fa3aa93f0f3a245ec391e341346182 to your computer and use it in GitHub Desktop.
using System;
using System.Threading;
class Program
{
class Flag
{
public bool done;
}
static void Main(string[] args)
{
var f = new Flag { done = false };
new Thread(() => Runner(f)).Start();
Thread.Sleep(1000);
f.done = true;
Console.ReadKey();
}
static void Runner(Flag f)
{
Console.WriteLine("Start");
while (!f.done) ;
Console.WriteLine("Done");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment