1
Answer

Problem In Threading

Smart    Lucky

Smart Lucky

12y
1.2k
1

Hi 

Can any one tell me i am beginner to Threading so when ever i am running this program it show some time Firlsy (functon 1 Execution) and some time show Firstly (Function 2 Execution) , now my question is that how much time each thread is taking for execution and what is the by default time of each thread ....?

using System;

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

namespace Threading_In_C_Sharp
{
class Program
{
static void WriteY()
{
for (int i = 0; i < 1000; i++) Console.Write("Y");

}

static void Main(string[] args)
{

Thread obj1 = new Thread(function1);
obj1.Start();
Thread obj2 = new Thread(funciton2);
obj2.Start();

}
public static void function1()
{
for (int i = 1; i <= 10; i++)
{
Console.WriteLine("Function 1 Execution" + i.ToString());

}
}
public static void funciton2()
{
for (int i = 1; i <= 10; i++)
{
Console.WriteLine("Function 2 Execution" + i.ToString());

}
}
}
}


Answers (1)