class ThreadClass
{
private int a;
private int b;
private int sum;
public ThreadClass(int a,int b) {
this.a = a;
this.b = b;
}
public void sumThread() {
this.sum = a + b;
}
public int getResult() {
return this.sum;
}
}
ThreadClass tc = new ThreadClass(100 , 150);
Thread tcTh = new Thread(tc.sumThread);
tcTh.Start();
tcTh.Join();//等待线程完成
Console.WriteLine(tc.getResult());可以看出,Thread线程参数接受静态方法,也接受成员方法
tcTh.Join() 表示等待线程完成,再运行下面的代码