Beispiel #1
0
        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;
        }
Beispiel #2
0
        static void ThreadWorker(ref DataMonitor dataMonitor, char letter)
        {
            bool response;

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