SemaPhoreDemo double acquire fix
tryAcquire() already acquires a permit, if one is available (no need to call acquire() after it)
@@ -12,7 +12,6 @@ public class SemaPhoreDemo {
System.out.println("Number of threads waiting to acquire: " + semaphore.getQueueLength());
if (semaphore.tryAcquire()) {
- semaphore.acquire();
// perform some critical operations
semaphore.release();
}
