Implementation of Semaphors in Java