1.

What Is The Difference Between Join And Sleep ?

Answer»

You can wait for another thread to end by calling its Join method. For EXAMPLE:

static void Main()

{

Thread t = new Thread (GO);

t.Start();

t.Join();

Console.WriteLine ("Thread t has ended!");

}

static void Go()

{

for (INT i = 0; i < 1000; i++) Console.Write ("y");

}

This prints “y” 1,000 times, followed by “Thread t has ended!” immediately afterward. You can include a timeout when calling Join, either in milliseconds or as a TimeSpan. It then RETURNS true if the thread ended or false if it timed out.

You can wait for another thread to end by calling its Join method. For example:

static void Main()

{

Thread t = new Thread (Go);

t.Start();

t.Join();

Console.WriteLine ("Thread t has ended!");

}

static void Go()

{

for (int i = 0; i < 1000; i++) Console.Write ("y");

}

This prints “y” 1,000 times, followed by “Thread t has ended!” immediately afterward. You can include a timeout when calling Join, either in milliseconds or as a TimeSpan. It then returns true if the thread ended or false if it timed out.



Discussion

No Comment Found