Cハハハ並列プログラミング【from msdn】
659 ワード
原文のリンク:http://www.albahari.com/threading/part5.aspx
// Thread.Sleep(TimeSpan.FromHours(1)); // sleep for 1 hour
// Thread.Sleep(500); // sleep for 500 milliseconds
1.static bool done;
static readonly object locker = new object();
static void Main()
{
new Thread (Go).Start();
Go();
}
static void Go()
{
lock (locker)
{
if (!done) { Console.WriteLine ("Done"); done = true; }
}
}
2. Thread t = new Thread(DoWrite);
t.Start();
t.Join();
Console.WriteLine("Thread t has ended!");