Implement semaphore pattern