You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/12/16 02:16:25 UTC

[GitHub] [rocketmq] drpmma commented on issue #5710: [code issue] the use of CountDownLatch2

drpmma commented on issue #5710:
URL: https://github.com/apache/rocketmq/issues/5710#issuecomment-1354084653

   > the `waitForRunning`'s behavior in the ServiceThread is indefinite in some worst cases.
   
   There is indeed a concurrent issue on `waitPoint`, but it will not lead to indefinite waiting.
   
   ```java
   protected void waitForRunning(long interval) { 
        if (hasNotified.compareAndSet(true, false)) { 
            this.onWaitEnd(); 
            return; 
        } 
     
        // 1. execute wakeup() here will cause a extra waiting
   
        waitPoint.reset(); 
     
       // 2. execute wakeup() here will lead to immediate wakeup without waiting
   
        try { 
            waitPoint.await(interval, TimeUnit.MILLISECONDS); 
        } catch (InterruptedException e) { 
            log.error("Interrupted", e); 
   ```
   
   As the annotation below, the `wakeup()` invocation before `waitPoint.reset()` will cause a extra waiting while `wakeup()` execution after `waitPoint.reset()` will lead to immediate wakeup without waiting.
   
   There is indeed a concurrent issue and do you have the indentation to submit to pr to fix 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: commits-unsubscribe@rocketmq.apache.org

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