Quote:
Originally Posted by IanWright
As pingw33n said, that isn't correct. The join method blocks the calling thread until the thread in question either stops or the timeout expires. All other threads will continue execution and new threads can be started from other threads of execution.
Hmm, I did some testing with the .join and it doesn't seem to block the calling thread, I believe all of you of course, but this is the code I used, if you could tell me where and how I am misinterpreting this, I'd greatly appreciate it.
For example, when I do this...
-
static void Main(string[] args)
-
{
-
Thread t1 = new Thread(methodName);
-
t1.Name = "t1";
-
t1.Start();
-
-
Thread t2 = new Thread(methodName);
-
t2.Name = "t2";
-
t2.Start();
-
-
t2.Join();
-
-
Thread t3 = new Thread(methodName);
-
t3.Name = "t3";
-
t3.Start();
-
}
-
-
static void methodName()
-
{
-
for (int x = 0; x < 10; x++)
-
{
-
Thread.Sleep(1000);
-
Console.WriteLine(Thread.CurrentThread.Name + " at " + x.ToString());
-
}
-
}
-
Both t1 and t2 continue running, and when t2 is finished, t3 starts. That is why I made my previous statement about what I thought .join was doing.