hahacjh
既然选择了远方 便只顾风雨兼程

在同一时间CPU只能执行一个线程

所以只有当本线程挂起或结束时才会执行其他线程

 

代码
class Program
{

public void Method1()
{
Console.WriteLine(
"Method1 is the starting point of excution of the thread");
}

static void Main(string[] args)
{
Program newp
= new Program();
Thread thread1
= new Thread(new ThreadStart(newp.Method1));
thread1.Start();

//1位置

Console.WriteLine(
"The excution of Sample Thread has started");

//2位置

thread1.Abort();

Console.ReadLine();


}
}

 

如果把Thread.Sleep(100);放在1位置则先输出结果为"Method1 is the starting point of excution of the thread"

如果把Thread.Sleep(100);放在2位置则先输出结果为"The excution of Sample Thread has started"

 

posted on 2010-03-30 11:52  hahacjh  阅读(1818)  评论(0编辑  收藏  举报