java how to use thread join using -'java,concurrency,join,multithreading'

java how to use thread join  using -'java,concurrency,join,multithreading'

I'm new to threads. How can I get t.join to work, whereby the thread calling it waits until t is done executing?

This code would just freeze the program, because the thread is waiting for itself to die, right?

public static void main(String[] args) throws InterruptedException {
    Thread t0 = new Thready();


public void run() {
    for (String s : info) {
        try {
        } catch (InterruptedException e) {
        System.out.printf("%s %s%n", getName(), s);

What would I do if I wanted to have two threads, one of which prints out half the info array, then waits for the other to finish before doing the rest?

asked Sep 7, 2015 by rajesh
0 votes

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.