wait for threads to finish before starting new ones