Wait and join for the threads to complete.