use semaphore to solve