Hi !!
I understand muli-threading as "parallel instances of execution" and i have a query in this regard. The following is a code and its output. I would like to how will you describe "what exactly is the join() method doing here?".
And the output is:
New
thread: Thread[One,5,main]
New thread: Thread[Two,5,main]
New thread: Thread[Three,5,main]
Thread One is Alive:true
Thread Two is Alive:true
Thread Three is Alive:true
Waiting for threads to finish.
One:5
Two:5
Three:5
One:4
Two:4
Three:4
One:3
Two:3
Three:3
One:2
Two:2
Three:2
One:1
Two:1
Three:1
Finished all the threads!!
Now is'n't it misleading to say that " join() waits until the thread on which it is called terminates. " ?
What it actually does is that it does not let the thread "from which it is being called" terminate,
till the thread "on which it is being called" terminates
The important thing to note is that after a call to join() in main, the control passes to the next join() and so on.
But it does not come out of the try{}catch{} block , as is evident from the last print statement. Thats seems like "magic".
Please enlighten me on this.
Thanx and Regards !!
radhakrishnan. j
(edited by Cindy to format code)
[This message has been edited by Cindy Glass (edited November 28, 2001).]