You have to set one semaphore to 0 and the other one to 1 initially so that only one thread can run at the beginning. Otherwise you'll never be acquiring a semaphore when it's at 0. I would use wait conditions here though. Or a single thread...