avatar
vimdur

Guest 25 4th Dec, 2019

                                           
                         using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace thread2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("main method starts");
            Thread t1 = new Thread(new ThreadStart(PrintInfo));
            Thread t2 = new Thread(new ThreadStart(PrintInfo1));
            t1.Start();
            t2.Start();
            Console.WriteLine("Main Thread Completed");
            Console.ReadLine();
        }
        static void PrintInfo()
        {
            for (int i = 1; i <= 10; i++)
            {
                if ((i % 2) != 0)
                {
                    Console.WriteLine("odd value :{0}", i);
                    Thread.Sleep(1000);
                }
            }
            Console.WriteLine("Child thread completed");
            
        }
        static void PrintInfo1()
        {
            for (int i = 1; i <= 10; i++)
            {
                if ((i % 2) == 0)
                {
                    Console.WriteLine("even value :{0}", i);
                    Thread.Sleep(1050);
                }
            }
            Console.WriteLine("Child thread1 completed");

        }
    }
}
                      
                                       
To share this paste please copy this url and send to your friends
RAW Paste Data
Recent Pastes