trying to implement semaphore and reentrantlock