A recursive semaphore written in Java