using System;
using System.Threading;
namespace ThreadWithParameters
{
class Program
{
static void Main(string[] args)
{
string hello = "hello world";
//如果写成Thread thread = new Thread(ThreadMainWithParameters(hello));这种形式,编译时就会报错
Thread thread = new Thread(() => ThreadMainWithParameters(hello));
thread.Start();
Console.Read();
}
static void ThreadMainWithParameters(string str)
{
Console.WriteLine("Running in a thread,received: {0}", str);
}
}
}
网友评论