Multiple Threads In C# ……………..

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

namespace Thread
{
    class Program
    {
        public void Start()
        {
            ThreadStart ts = new ThreadStart(run);
            Thread t1 = new Thread(ts);
            Thread t2 = new Thread(ts);
            Thread t3 = new Thread(ts);

            t1.Start();
            t2.Start();
            t3.Start();
        }

        public void run()
        {
            for (int i = 0; i < 100; i++)
            {
                Console.WriteLine("Counter = {0}", i);
            }
        }

        static void Main(string[] args)
        {
            Program p = new Program();
            p.Start();

            Console.Read();
        }
    }
}

SHARE THE KNOWLEDGE


  

Advertisements

About Dinesh

I am engineering student........ I am selected in Microsoft Student Partner as MSP............

Posted on August 14, 2011, in .NET, C#, Knowledge. Bookmark the permalink. Leave a comment.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: