您的位置:首页 > 其它

启用一个线程的Start方法

2013-04-27 22:10 295 查看
启动一个线程是调用 start() 方法,new一个ThreadStart class, 然后,把ThradStart class对象传给Thread类,Thread类start()

View Code

public class ThreadWork
{
public static void DoWork()
{
for (int i = 0; i < 5; i++)
{
Console.WriteLine("Working thread..{0}", i);
Thread.Sleep(100);
}
}
}

class Program
{
static void Main(string[] args)
{
ThreadStart myStart = new ThreadStart(ThreadWork.DoWork);
Thread myThread = new Thread(myStart);

//启用一个Thread
myThread.Start();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐