JavaGian java tutorial and java interview question and answer

JavaGian , Free Online Tutorials, JavaGian provides tutorials and interview questions of all technology like java tutorial, android, java frameworks, javascript, ajax, core java, sql, python, php, c language etc. for beginners and professionals.

Showing posts with label Thread-Join. Show all posts
Showing posts with label Thread-Join. Show all posts

Java Thread Join Example

7:45 AM
There are three variant of join method: public final void join() throws InterruptedException : Thread on which join method is getting called to die. public final void join(long millis) throws InterruptedException: This method when called on the thread, it waits for either of following: Thread on which join method is getting called, to die. Specified milliseconds public final void join(long millis,int nanos) throws InterruptedException: This method when called on the thread, it waits for either of following: Thread on which join method is getting called, to die. Specified milliseconds + nano seconds Example: Lets take simple example: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19   package org . arpit . java2blog . thread ;   public class MyRunnable implements Runnable {   public void run ( ) {    try {    System . out . println ( Thread . currentThread ( ) . getName

.