using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; using System.Threading; namespace Pi { class Program { static void Main(string[] args) { double pi_wy, sum_wy = 0.0, seri_t_wy, para_t_wy; Stopwatch stopwatch = new Stopwatch(); Pi_Thread ParallelOne = new Pi_Thread(1); ThreadStart StartOne = new ThreadStart(ParallelOne.Pi_paral); Thread newThreadOne = new Thread(StartOne); Pi_Thread threadTwo = new Pi_Thread(2); ThreadStart StartTwo = new ThreadStart(threadTwo.Pi_paral); Thread newThreadTwo = new Thread(StartTwo); stopwatch.Start(); newThreadOne.Start(); newThreadTwo.Start(); newThreadOne.Join(); newThreadTwo.Join(); stopwatch.Stop(); TimeSpan wy_timeSpan_paral = stopwatch.Elapsed; sum_wy = ParallelOne.sum + threadTwo.sum; pi_wy = ParallelOne.step * sum_wy; para_t_wy = wy_timeSpan_paral.TotalMilliseconds; Console.WriteLine("並行結果: " + pi_wy); Console.WriteLine("並行 並行 並行結果: 3.141592633590 並行 加速比: 1.94045561251595