Sapna
How to create a new process thread and stop it?
By Sapna in ASP.NET on Jul 20 2010
  • manzoor abdul
    Jul, 2010 23

    Class ThreadExample{

     

    static void Main(String[] args)

    {

              ThreadExample  example= new ThreadExample();

               Thread Message1= new Thread(New ThreadStart(example.DisplayMessage));

               Thread Message2= new Thread(New ThreadStart(example.DisplayMessage2));

              // to start a thread1

                Message1.Start()

              // to start a thread2

                Message2.Start()

             //  There should not be option to stop a Thread

               //but possiblt to suspend a thread  using Suspend Property,It will not do anything if

               //thread execution  gets  completed

    }

    public void DisplayMessage()

     {

                for(int i=0;i<20;i++)

              {

                 Console.writeLine(i)

               }

     

    }

     

    public void DisplayMessage2()

     {

                for(int i=21;i<40;i++)

              {

                 Console.writeLine(i)

               }

     

    }

     

    }

     

     

     

     

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS