Hoons.Net/C#

캠퍼스 시삽 과제 3-2) 컬렉션 점찍어 출력하기(Parallel Ver.)

Houkibosi 2012. 8. 13. 16:56

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Collections;

using System.Threading.Tasks;


namespace ConsoleApplication3

{

    class Program

    {

        static void Main(string[] args)

        {

            int time = 0, time2=0;

            StringBuilder str = new StringBuilder();

            ArrayList list = new ArrayList();


            for (int i = 0; i < 100000; i++) 

            {

                list.Add("이재민" + i);

            }

            


            time = Environment.TickCount;


            // 병렬처리 코드

            //Parallel.For(0, list.Count - 1, i=> { str.Append(list[i++] + ", "); });

            //str.Append(list[list.Count - 1] + "\n\n");

            //Console.WriteLine(str);

            


            // 단일처리 코드

            //for (int i = 0; i < list.Count - 1; str.Append(list[i++] + ", ")) { }

            //str.Append(list[list.Count - 1] + "\n\n");

            //Console.WriteLine(str);

            


            time2 = Environment.TickCount;

            Console.WriteLine(time2 - time);

        }

    }

}