Source Code : Wait the for the completion of a thread
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Wait the for the completion of a thread
public class Main {
public static void main(String a[]) throws Exception {
MyThread tt1 = new MyThread(50);
MyThread tt2 = new MyThread(75);
Thread t1 = new Thread(tt1, "Test thread 1");
Thread t2 = new Thread(tt2, "Test thread 2");
t1.start();
t2.start();
t1.join();
t2.join();
}
}
class MyThread implements Runnable {
int i;
MyThread(int i) {
super();
this.i = i;
}
public void run() {
System.out.println(Thread.currentThread().getName() + " " + i);
}
}
Thank with us