Update SemaPhoreDemo.java
This commit is contained in:
parent
efb631f017
commit
7f51ae04c0
@ -11,7 +11,7 @@ public class SemaPhoreDemo {
|
|||||||
System.out.println("Available permit : " + semaphore.availablePermits());
|
System.out.println("Available permit : " + semaphore.availablePermits());
|
||||||
System.out.println("Number of threads waiting to acquire: " + semaphore.getQueueLength());
|
System.out.println("Number of threads waiting to acquire: " + semaphore.getQueueLength());
|
||||||
|
|
||||||
if (semaphore.tryAcquire())
|
if (semaphore.tryAcquire()) {
|
||||||
try {
|
try {
|
||||||
// perform some critical operations
|
// perform some critical operations
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user