线程中传递参数

 1         static void Main(string[] args)
 2         {
 3             ParameterizedThreadStart doWork = new ParameterizedThreadStart(getMethod);
 4             Thread th = new Thread(doWork);
 5             object obj = new string[] { "a""b""c""d""e""f""g" };
 6             th.Start(obj);                   
 7         }
 8         public static void getMethod(object c)
 9         {
10             string[] a = (string[])c;
11             foreach (string s in a) {
12                 Console.Write(s);
13                 Thread.Sleep(1000);
14             }
15             Console.ReadLine();
16         }

posted on 2014-09-25 19:34  内瑟斯  阅读(174)  评论(0编辑  收藏  举报

导航