Originally posted by Gautam Pandey:
join() will stop current executing thread for sure in which it is called
and
start new thread which is calling join().
I am not able to understand this line.
If your thread calling join() on my thread, then your thread will stop executing and wait until my thread completes its work and die. If my thread does not complete its work, then your thread will wait for my thread forever.
If you are calling
main(){
...
t1.start();
t1.join();// here main thread is calling join() on t1 thread, so main thread will wait until t1 thread completes its work.
...
}