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/19 08:55:21 UTC

[GitHub] [rocketmq] fuyou001 commented on a diff in pull request #5713: [ISSUE #5710] optimize ServiceThread's waitForRunning logic

fuyou001 commented on code in PR #5713:
URL: https://github.com/apache/rocketmq/pull/5713#discussion_r1051948958


##########
common/src/main/java/org/apache/rocketmq/common/ServiceThread.java:
##########
@@ -133,13 +149,17 @@ protected void waitForRunning(long interval) {
         }
 
         //entry to wait
-        waitPoint.reset();
-
+        lock.lock();
         try {
-            waitPoint.await(interval, TimeUnit.MILLISECONDS);
+            if (!hasNotified.get())
+            {
+                //ignore return value
+                waitPoint.await(interval, TimeUnit.MILLISECONDS);
+            }
         } catch (InterruptedException e) {
             log.error("Interrupted", e);
         } finally {
+            lock.unlock();

Review Comment:
    hasNotified.set(false); 
   lock.unlock();
   
   if first unlock,may be miss a wait 
            



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