Wednesday 12 August 2015

Java Thread Join Example

join() method in Java Thread : The join() method of a Thread class allows the current thread to wait until the thread in which it is called will die. Sometime a question is asked in the interviews that How can we make sure main() is the last thread to finish in Java Program? So the answer is here that the join() method is give to the way to confirm that all the child threads are finished execution before main thread terminated.



There are three overloaded join functions:
  1. public final void join(): This method pause the current thread until the thread on which it’s called is terminated.If in any case the current thread is interrupted It throws InterruptedException.
  2. public final synchronized void join(long millis): This method is used to pause the thread on which it’s called to be terminated(dead) or wait for specified milliseconds......
To read full blog about Java Thread Join Example visit FindNerd
Get in contact with FindNerd's tech experts for various programming problems. Nowadays most of the queries asked by users is from java developer forum section

No comments:

Post a Comment