Tibor17 edited a comment on pull request #77:
URL: https://github.com/apache/maven-resolver/pull/77#issuecomment-817381029


   I think no lock is needed if you use the thread pool because there you say 
that the fixed number of threads is e.g. 5.
   Deadlock happens if you use multiple lock objects. Why we need to have 
multiple locks?
   If we want to block the business method until `Collection<Artifact>` is 
processed completely then we can do it via listeners notified by the thread 
pool and we can use `CountdownLatch` but the `CountdownLatch` would be only one 
in business-method stack and the size of the countdown would be equal to the 
size of the input collection.
   The basic principle of the deadlock using the mutex is this:
   
   **T1**:
   ```
   synchronized(lock1) {
       synchronized(lock2) {
          // job here
       }
   }
   ```
   
   **T2**:
   ```
   synchronized(lock2) {
       synchronized(lock1) {
          // another job here
       }
   }
   ```


-- 
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to