public static void Main()
        {
            // The default constructor is called for ExampleThread
            // and an object is instantiated of type ExampleThread
            ExampleThread mainThread = new ExampleThread("Thread ");

            // The Sleep method is called to suspend the thread for 1 second
            Thread.Sleep(1000);
            Console.WriteLine("Stop thread");

            // A ThreadAbortException is raised and the thread is terminated
            mainThread.threadOne.Abort(100);

            mainThread.threadOne.Join();
            Console.WriteLine("Main thread is terminating");
        }
Пример #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Main Thread Started");

            ExampleThread thread1 = new ExampleThread("thread1");
            ExampleThread thread2 = new ExampleThread("thread2");
            ExampleThread thread3 = new ExampleThread("thread3");

            do
            {
                Console.WriteLine("< Threads Active >");

                Thread.Sleep(200);
            } while (thread1.thr.IsAlive && thread2.thr.IsAlive && thread3.thr.IsAlive);

            Console.WriteLine("Main Thread Finished");
            Console.ReadLine();
        }