Use a semaphore instead of a while() sleep to check for available threads