class Program
{
static void Main(string[] args)
{
ParameterizedThreadStart aStart = new ParameterizedThreadStart(Addition);
Thread aThread = new Thread(aStart);
Data aData = new Data();
aData.X = 10;
aData.Y = 20;
aThread.Start(aData);
aThread.Join();
Console.WriteLine("End of the program");
}
static void Addition(object data)
{
var a = data as Data;
var b = a.X + a.Y;
a.result = b;
Console.WriteLine(a.result);
Thread.Sleep(1000);
Console.WriteLine("End of thread");
}
}
I have written an example to understand the Join method();
Can any body explain how it works ? and what is the difference between sleep and join()
Joinwaits until the thread you’ve called it on stops.Sleepsleeps for a given time period.