第3个回答 推荐于2017-10-03
代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace ThreadDemo
{
class Program
{
static void Main(string[] args)
{
//实例化类,为线程提供参数
Demo d1=new Demo(1,4);
Demo d2=new Demo(11,15);
Thread th1 = new Thread(new ThreadStart(d1.start));
Thread th2 = new Thread(new ThreadStart(d2.start));
th1.Start();
Thread.Sleep(1000);
th2.Start();
}
}
class Demo
{
private int a;
private int b;
public Demo(int aa, int bb)
{
this.a = aa;
this.b = bb;
}
public void start()
{
for (int i = a; i < b; i++)
{
Console.WriteLine(i.ToString());
}
}
}