参考:点击打开链接
using System;
using System.Threading;
public class MyThread
{
public double Diameter = 10;
public double Result = 0;
public MyThread(int Diameter)
{
this.Diameter = Diameter;
}
public void Calculate()
{
Console.WriteLine("Calculate Start");
Thread.Sleep(2000);
Result = Diameter * Math.PI;
Console.WriteLine("Calculate End, Diameter is {0},Result is {1}", this.Diameter, Result);
Console.Read();
}
}
public class Test
{
public static void Main(String[] args)
{
MyThread t = new MyThread(5);
ThreadStart threadStart = new ThreadStart(t.Calculate);
Thread thread = new Thread(threadStart);
thread.Start();
}
}