using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace ConsoleApplication3
{
class Program
{ static void Main(string[] args)
{
Class1 cs = new Class1();
Thread th = new Thread(new ThreadStart(cs.test1));
Thread th2 = new Thread(new ThreadStart(cs.test2));
th.Start();
th2.Start();
Console.ReadKey();
} }
public class Class1
{
public void test1()
{
lock (this)
{
Console.WriteLine("test1");
Thread.Sleep(2000);
}
}
public void test2()
{
lock (this)
{
Console.WriteLine("test2");
Thread.Sleep(2000);
}
}
}
}
这个程序中:
Thread th = new Thread(new ThreadStart(cs.test1));
Thread th2 = new Thread(new ThreadStart(cs.test2));
这两句是什么意思 看不懂 请指教 请尽量详细 十分感谢
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace ConsoleApplication3
{
class Program
{ static void Main(string[] args)
{
Class1 cs = new Class1();
Thread th = new Thread(new ThreadStart(cs.test1));
Thread th2 = new Thread(new ThreadStart(cs.test2));
th.Start();
th2.Start();
Console.ReadKey();
} }
public class Class1
{
public void test1()
{
lock (this)
{
Console.WriteLine("test1");
Thread.Sleep(2000);
}
}
public void test2()
{
lock (this)
{
Console.WriteLine("test2");
Thread.Sleep(2000);
}
}
}
}
这个程序中:
Thread th = new Thread(new ThreadStart(cs.test1));
Thread th2 = new Thread(new ThreadStart(cs.test2));
这两句是什么意思 看不懂 请指教 请尽量详细 十分感谢
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货