[C#] Multi Thread

摘要:[C#] Multi Thread

public void Go()
{


Thread t = Thread.CurrentThread;
Console.WriteLine("before enter: " + t.Name);
lock (this)

{


Console.WriteLine("after enter: " + t.Name);

if (! m_Married)


{


Thread.Sleep(1000);
m_Married = true;
Console.WriteLine("changed: " + t.Name);


}

else
{


Console.WriteLine("no changed: " + t.Name);


}


Console.WriteLine("before exit: " + t.Name);

}


Console.WriteLine("after exit: " + t.Name);


}