110,539
社区成员
发帖
与我相关
我的任务
分享
public void Fun()
{
lock (this)
{
num = 555;
Console.WriteLine("线程一锁住this了{0}", num);
Console.WriteLine("当前对象:{0}",this.GetHashCode());
Thread.Sleep(6000);
Console.WriteLine("线程一锁解开this了");
}
}
public void Fun2()
{
lock (this)
{
num = 999;
Console.WriteLine("线程二锁住this了{0}", num);
Console.WriteLine("当前对象:{0}", this.GetHashCode());
Thread.Sleep(6000);
Console.WriteLine("线程二锁解开this了");
}
}