semaphore example for thread