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 10:02:31 UTC

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

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


##########
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:
   can you show me a more detailed execution order.
   
   should this line `if (!hasNotified.get())` be enough?
   



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