aarmam opened a new issue, #10409:
URL: https://github.com/apache/ignite/issues/10409

   Hi, 
   I have a question about race condition on closing semaphores. As I 
understand semaphores are not removed automatically and must therfore be closed 
manually. Lets say two threads want to change some object and try to aquire 
semaphore for it: 
   
   ```java
   IgniteSemaphore semaphore = ignite.semaphore(objectId, 1, true, true);
   if (semaphore.tryAcquire(5, TimeUnit.SECONDS)) {
       try {
           changeObject(objectId);
       } finally {
           semaphore.release(); // First thread releases semaphore
           // Second thread aquires semaphore
           semaphore.close(); // First thread closes semaphore
       }
   }
   ```
   1) What happens if first thread tries to close semaphore while second thread 
has aquired it?
   2) But my main quiestion is - can I close the semaphote without calling 
release before it? So second thread cannot aquire it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to