哪位高手可以给我详细解释C#中线程下这个列子。。

来源:百度知道 编辑:UC知道 时间:2024/06/05 10:57:56
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace Text
{
class BasicThreadApp
{
public static void ChildThreadCall()
{
Console.WriteLine("Child thread started.");
}
public static void Main(string[] args)
{
ThreadStart ChildRef = new ThreadStart(ChildThreadCall);
Console.WriteLine("Main - Creating Child thread.");

Thread ChildThread = new Thread(ChildRef );
ChildThread.Start();

Console.WriteLine("Main - Have requested the start of child thread.");
Console.ReadLine();
}
}
}

我不明白什么时候使用,为什么要带参数··· 哪个线程是先开始的··

ThreadStart ChildRef = new ThreadStart(ChildThreadCall); 这个只是申明一个委托..他的意思是线程启动后调用ChildThreadCall方法

Thread ChildThread = new Thread(ChildRef ); 这个是申明一个线程,他必须要一个线程委托参数,也就是ThreadStart
ChildThread.Start(); 这句话才是正式表明线程启动

http://msdn.microsoft.com/zh-cn/library/ms173178(VS.80).aspx