add semaphore to synchronize the starts of threads