xiaoyifang opened a new issue, #5710:
URL: https://github.com/apache/rocketmq/issues/5710

   background:
   the CountDownLatch2 is only used in ServiceThread .
   it is a reimplementation of CountDownLatch and offered a new method reset.
   
   I think the CountDownLatch2 can be replace with java `Condition` class for 
the following reasons:
   1, CountDownLatch does not offer reset ,as it was designed according to the 
javadoc ,
   
![image](https://user-images.githubusercontent.com/105986/208000791-4cdd1ed8-9037-4bce-9e64-ad03594ba32a.png)
   2, the instruction order in the ServiceThread is indefinit in  some worst 
cases.
   the code is in the ServiceThread. and the reset in used in `waitForRuning`.
   
https://github.com/apache/rocketmq/blob/aa7a442505ac012d1bc61b89bf10c41646a15005/common/src/main/java/org/apache/rocketmq/common/ServiceThread.java#L129-L141
   
   in multithread environment.
   
![image](https://user-images.githubusercontent.com/105986/208002112-cad2d8e5-6a9d-44cd-a9e3-98108191e9d7.png)
   
   the execution order will have different result ,and in the worst cases ,  
`waitForRunning` will have to wait some extra `interval` more millionseconds.
   
   
   


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