关于Thread的问题,高手请进!
通过线程类传递参数:public class TestThread
{
private int i;
public TestThread(int o)
{
i = o;
}
public void RunThread(){
while (mainthread.ThreadState == ThreadState.Running)//这个地方检测主线程的状态,怎么样能把mainthread传进来??
{
//计算线程
if(i>0){
计算...
}
}
}
}
这样写?:
public class TestThread
{
private int i;
private Thread mainthread;
public TestThread(int o,Thread t)
{
i = o;
mainthread=t;
}
public void RunThread(){
while (mainthread.ThreadState == ThreadState.Running)
{
//计算线程
if(i>0){
计算...
}
}
}
}
好像不对,求高手支招!
补充:.NET技术 , C#