More semaphores in Java code