Last active
September 23, 2016 06:28
-
-
Save yutopio/e0fa3aa93f0f3a245ec391e341346182 to your computer and use it in GitHub Desktop.
This file contains 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 | |
{ | |
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