Implementation of a FiFo semaphore in Java