public class join implements Runnable {
@Override
public void run() {
for (int x = 1; x <= 3; x++) {
System.out.println("this is thread "
+ Thread.currentThread().getName());
}
}
public static void main(String[] args) throws Exception {
join j1 = new join();
Thread t1 = new Thread(j1, "1");
Thread t2 = new Thread(j1, "2");
Thread t3 = new Thread(j1, "3");
t1.start();
t1.join();
t2.start();
t3.start();
}
}
Output :
this is thread 1 this is thread 1 this is thread 1 this is thread 3 this is thread 2 this is thread 2 this is thread 2 this is thread 3 this is thread 3If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.