Wednesday, 10 February 2016

C# Program how to Create a Simple Thread

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

class SimpleThread
{
    public void ThreadFunction()
    {
        for (int i = 0; i < 5; i++)
        {
            Console.WriteLine("Created Simple Thread");
        }
    }
}
class threprog
{
    public static void Main()
    {
        SimpleThread pg = new SimpleThread();
        Thread thread = new Thread(new ThreadStart(pg.ThreadFunction));
        thread.Start();
        Console.Read();
    }
}
--------------------
OUTPUT:-
Created Simple Thread
Created Simple Thread
Created Simple Thread
Created Simple Thread
Created Simple Thread
------------------------------------------------

No comments:

Post a Comment