Console Application for Threading using System.Threading in C# 1.1 and 2.0 (Dot Net)

Google+ Pinterest LinkedIn Tumblr +

// Console Application for Threading using System.Threading in C# 1.1 and 2.0 (Dot Net)

using System;

using System.Threading;

namespace Thred

{

class Thred

{

static void Main()

{

            cs mt=new cs();

mt.t1=new Thread(new ThreadStart(mt.method1));

mt.t2=new Thread(new ThreadStart(mt.method2));

mt.t1.Start();

mt.t2.Start();

Console.ReadLine();

}

}

class cs

{

public Thread t1,t2;

public void method1()

{

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

{

Console.WriteLine(“Thread1 “+ j);

Thread.Sleep(1000);

}

            t2.Suspend();

t2.Resume();

}

public void method2()

{

t1.Suspend();

t1.Resume();

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

{

Console.WriteLine(“Thread2 “+ i);

Thread.Sleep(2000);

}

}

}

}

Share.

About Author

Leave A Reply