예제 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            //the thread class
            ThreadPrg thrprg = new ThreadPrg();

            //new thread to get a random temperatur
            Thread rndtempThread = new Thread(thrprg.RandomTempMethod);

            rndtempThread.Start();


            Thread checktemp = new Thread(thrprg.CheckTempMethod);

            checktemp.Start();


            while (true)
            {
                Thread.Sleep(10000);
                if (!checktemp.IsAlive)
                {
                    Console.WriteLine("Alarm-tråd termineret!");
                    Environment.Exit(1);
                }
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            //Thread Class
            ThreadPrg tp = new ThreadPrg();

            //printer thread
            Thread printerThread = new Thread(tp.PrintMethod);

            printerThread.Start();

            //reader thread
            Thread readerThread = new Thread(tp.ReadMethod);

            readerThread.Start();
        }