日期:2014-05-17 浏览次数:20830 次
/// <summary>
/// 类ThreadA
/// </summary>
public class ThreadA
{
private Thread Th;
private int number;
public ThreadA(int n)
{
Th = new Thread(new ThreadStart(this.Run));
this.number = n;
}
public void Start()
{
if (Th != null)
{
Th.Start();
}
}
private void Run()
{
if (this.number > 0)
{
//线程执行方法代码,略……
}
}
}
/// <summary>
/// 类ThreadB
/// </summary>
public class ThreadB
{
private int number;
public ThreadB(int n)
{
this.number = n;
}
public void Run()
{
if (this.number > 0)
{
//线程执行方法代码,略……
}
}
}
class Program
{
static void Main(string[] args)
{
//方式一:使用ThreadA类创建3个线程
ThreadA ThA1 =