예제 #1
0
파일: Program.cs 프로젝트: rromikas/cards
        static void Main(string[] args)
        {
            DataMonitor   zodis   = new DataMonitor();
            List <Thread> threads = new List <Thread>();

            char[] raides        = new char[] { 'A', 'B', 'C' };
            bool   threadsJoined = false;


            for (int i = 1; i <= 3; i++)
            {
                threads.Add(new Thread(() => ThreadWorker(ref zodis, raides[i])));
            }

            while (!threadsJoined)
            {
                Console.WriteLine(zodis.ToString());
            }

            threads.ForEach(thread =>
            {
                thread.Start();
            });

            threads.ForEach(thread =>
            {
                thread.Join();
            });

            threadsJoined = true;
        }
예제 #2
0
파일: Program.cs 프로젝트: rromikas/cards
        static void ThreadWorker(ref DataMonitor dataMonitor, char letter)
        {
            bool response;

            while ((response = dataMonitor.AddLetter(letter)))
            {
            }
        }