Add a semaphore to avoid concurrency.