Start everything, then join
Start everything, then join
Answer
List<Thread> threads = new ArrayList<>(); for (String host : args) { Resolver task = new Resolver(host); Thread t = new Thread(task); t.start(); threads.add(t); } for (Thread t : threads) t.join(); // every result is now written and visible
The two loops are the whole idiom: the first overlaps every wait, the second collects. Fusing them into one loop (start then immediately join) would serialise the program while looking concurrent.
Harold 4e ch3 §Returning Information from a Thread