Wait until all threads finished.