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