C#マルチスレッドパラメータ


    class test
{
private int i ;
private string s;
public test(int n1,string s1)
{
this.i = n1;
this.s = s1;
}
public void Withparameters()
{
Console.WriteLine(" , {0},{1}",i,s);
}
}
class Program
{
static void Main()
{
Thread th = new Thread(new ParameterizedThreadStart(WithParameters));// parameterizedThreadStart object 。 object ,
th.Start("ParameterizedthreadStart");
test t=new test(123," ");//
Thread th1 = new Thread(t.Withparameters);
th1.Start();
Thread th2 = new Thread(() => WithParameters("lambda"));//lambda 。
th2.Start();
Console.ReadKey();
}
static void WithParameters(object obj)
{
string o = obj as string;
if (!string.IsNullOrEmpty(o))
{
Console.WriteLine(" , {0}",o);
}
}
}