using System;using System.Collections.Generic;using System.Text;using System.Threading;using System.Diagnostics;namespace TestMultiThread{ class PRogram { pp s = new pp(); static void Main(string[] args) { Program dd = new Program(); Thread th; for (int i = 0; i < 10; i++) { th= new Thread(new ThreadStart(dd.Test)); th.Name = i.ToString(); th.Start(); Thread.Sleep(10); } Console.WriteLine("wait 3 seconds"); Console.ReadKey(); } public void Test() { Int32 i = 0; i++; Console.WriteLine("name:{0}/I vaule:{1}", Thread.CurrentThread.Name,i.ToString()); s.ps(); } } class pp { public void ps() { Int32 i=0; Thread.Sleep(3000); i++; Console.WriteLine("ps:name:{0}/i:{1}", Thread.CurrentThread.Name,i.ToString()); } }}
测试代码:
新闻热点
疑难解答