C# Program to Create a Thread

You are currently viewing C# Program to Create a Thread

C# program to create a thread

/*
 * Program to create a thread in C#
 */
using System;
using System.Threading;

class ThreadEx
{
    public void MyThreadFun()
    {
        int i = 0;
        for (i = 1; i<=4; i++)
        {
            Console.WriteLine("Thread Executed");
        }
    }
}
class Program
{
    public static void Main()
    {
        ThreadEx T = new ThreadEx();
        Thread t1 = new Thread(new ThreadStart(T.MyThreadFun));
        t1.Start();
    }
}
Thread Executed
Thread Executed
Thread Executed
Thread Executed

Ranjith Kumar

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply