How to wait until all threads finish their work in java
One more example
Another way to save the values return by the threads:
Another way is to join to the threads. The join blocks until the thread completes.
Note that join throws an InterruptedException. You'll have to decide what to do if that happens.