Merge pull request #7927 from IgorNB/patch-1
SemaPhoreDemo double acquire fix
This commit is contained in:
commit
fdf812510f
@ -12,9 +12,11 @@ public class SemaPhoreDemo {
|
||||
System.out.println("Number of threads waiting to acquire: " + semaphore.getQueueLength());
|
||||
|
||||
if (semaphore.tryAcquire()) {
|
||||
semaphore.acquire();
|
||||
try {
|
||||
// perform some critical operations
|
||||
semaphore.release();
|
||||
} finally {
|
||||
semaphore.release();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user