using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("线程开始");
Thread t = new Thread(new ParameterizedThreadStart(Demo));//注意ParameterizedThreadStart委托的定义形式
t.Start(new string[] { "Oh","My","God" });
Console.WriteLine("线程继续执行");
Thread.Sleep(1000);
t.Abort();
t.Join();//阻塞Main线程,直到t终止
Console.ReadKey();
}
static void Demo(object s)
{
string[] strarry = s as string[];
while (true)
{
Console.WriteLine("{0}--{1}--{2}", strarry[0], strarry[1], strarry[2]);
}
}
}
}
线程启动一个带一个参数的方法
最新推荐文章于 2019-07-31 01:46:38 发布