线程Thread

//启动线程
thread = new Thread(new ThreadStart(HelloWorld));
thread.Start();

protected void HelloWorld()
{
string str ;
Console.write("helloworld");
}
}

//杀死线程
if ( thread.IsAlive )
{
thread.Abort();
}

//暂停线程
thread.Sleep();

//设定线程优先级
//包括Normal, AboveNormal, BelowNormal, Highest, and Lowest几种
thread.Priority = ThreadPriority.Highest;

//挂起线程
if (thread.ThreadState = ThreadState.Running )
{
thread.Suspend();
}

//唤起线程
if (thread.ThreadState = ThreadState.Suspended )
{
thread.Resume();
}

 

 

 

posted @ 2007-08-27 18:03  RobotTech  阅读(525)  评论(0编辑  收藏  举报