bug fix relating to same semaphore, different thread