日期:2014-05-17 浏览次数:20807 次
for (int i = 0; i < 7; i++)
{
Doit(mm);
}
public static void Doit(object Dom)
{
Console.WriteLine("A"+DateTime.Now);
string ml = "";
for (int i = 0; i < 10000; i++)
{
ml += DateTime.Now.ToString();
//Console.WriteLine(DateTime.Now);
}
Console.WriteLine(DateTime.Now);
}
Thread[] ths = new Thread[12];//创建线程集合体
ParameterizedThreadStart[] pst = new ParameterizedThreadStart[12];//创建带参数的线程委托
for (int m = 0; m < 7; m++)
{
int f = m + 10;
pst[m] = new ParameterizedThreadStart(Doit);//将函数作为参数传递到线程委托中
ths[m] = new Thread(pst[m]);//实例化线程
object o = "A";//将对象封装成Object
ths[m].Start(o);//传参数启动线程
}
public static void Doit(object Dom)
{
Console.WriteLine("A"+DateTime.Now);
string ml = "";
for (int i = 0; i < 10000; i++)
{
ml += DateTime.Now.ToString();
//Console.WriteLine(DateTime.Now);
}
&nbs