日期:2014-05-18 浏览次数:20945 次
需要注意的是怎样给线程传递参数。
using System;
using System.Collections.Generic;
using System.Data.OleDb;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading;
namespace Test
{
public class Program{
public test(){
TestObject t = TestObject("sky素年锦时");
Thread thread = new Thread(hello);
thread.Start(t);
}
//线程执行的代码,o为传递的参数对象
public void hello(Object o){
Console.Out.WriteLine("Hello, this is " + o.name);
}
}
class TestObject{
public String name;
public TestObject(){
this.name= name;
}
}
}
?