using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace 多线程 { class 线程传数据 { public static void Main() { //Console.WriteLine( "主线程输出" ) ; //Thread t1 = new Thread( Run ) ; //t1.Name = "线程1" ; //t1.Start() ; //Thread t2 = new Thread(Run); //t2.Name = "线程2"; //t2.Start(); Data data = new Data(); data.Messages = "一直没说心里的潜台词,是怕你受不了这样的打击"; Thread t1 = new Thread(ThreadMainWithParams); t1.Start(data); Console.ReadLine(); } public struct Data { public string Messages; } public static void ThreadMainWithParams(Object o) { Data data = (Data)o; Console.WriteLine("内容{0}", data.Messages); } public static void Run() { Console.WriteLine("线程名{0}", Thread.CurrentThread.Name); } } }