I'm currently learning C# by reading books, and I'm not quite understanding Thread.Join.
So let's say I have the following code in Main:
ThreadStart start = Counting;
Thread thread = new Thread(start);
Thread thread2 = new Thread(start);
thread.Start();
thread2.Start();
thread.Join();
thread2.Join();
So basically by calling Join(), it blocks the thread Main is on until both threads stop running? By thread and thread2 don't have to wait for each other to terminate? So Join only blocks the thread that called it and not other threads?
I just want to make sure I have a correct understanding of this. Any help would be appreciated, thanks!
Loading
AlanPosted Jul 30, 2008, 4:41 PM
Your understanding of the Thread.Join() method is entirely correct.
Incidentally, below is a link to a great online resource on threading which is a sample chapter from a book I have:
http://www.albahari.com/threading/