日期:2014-05-17 浏览次数:20802 次
namespace ConsoleApplication1 { class Program { static void Main(string[] args) { for (int i = 0; i < 100;i++ ) { Class1 classtest = new Class1(); classtest.startdownthread(); } Console.WriteLine("end of for loop"); Thread.Sleep(1000); Console.ReadKey(); } } class Class1 { private int[] age; private Thread CalulateThread; public Class1() { CalulateThread = null; age = new int[1024]; } public void startdownthread() { CalulateThread = new Thread(Caculate); CalulateThread.IsBackground = true; CalulateThread.Start(); } private void Caculate() { //做一些很费时的工作如数值计算等 Thread.Sleep(1000); Console.WriteLine(GetHashCode()); return; } } }