i did't understand the purpose of "JOIN()" method.please help me.
now, i have been learning java.i follow the book called "THE COMPLETE REFERENCE".
Suppose you're building a house for me and I want to move in. I have nothing
else to do so I 'join' you until you're finished; then I can do what I want to do:
move in to my new house. The joining doesn't imply I start working on my future
house though, I simply wait until you have finished doing your job, then I wake
up and move in.
So...in essence you are starting the "move in" thread right after the "build house" thread is complete, or maybe coupling the to threads together like cars on a train?
So...in essence you are starting the "move in" thread right after the "build house" thread is complete, or maybe coupling the to threads together like cars on a train?
Yep, the "move" thread joins the "build" thread. When the "build" thread is
finished the "move" thread wakes up again. That's what the join() method does.
As long as the "build" thread isn't finished, the "move" thread keeps on sleeping.
Comment