tomy

tomy

  • NA
  • 2
  • 0

Newbie question on threads

Jul 30 2008 2:19 PM
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!

Answers (1)