CycleMaker opened a new issue, #14119:
URL: https://github.com/apache/dubbo/issues/14119

   ### Pre-check
   
   - [X] I am sure that all the content I provide is in English.
   
   
   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) and found no 
similar feature requirement.
   
   
   ### Apache Dubbo Component
   
   Java SDK (apache/dubbo)
   
   ### Descriptions
   
   This is the source code of the ThreadlessExecutor waitAndDrain method:
   
   
https://github.com/apache/dubbo/blob/ca7151e53166fc69079fefff074ee369aa29f134/dubbo-common/src/main/java/org/apache/dubbo/common/threadpool/ThreadlessExecutor.java#L52-L80
   It seems that if waitAndDrain is called twice in a multi-threaded scenario, 
there will be no wait on the second execution because if the cas fails, it will 
return. Here is my test code:
   
   > @Test
   >     void testV2() throws InterruptedException {
   >         new Thread(()->{
   >             try {
   >                 executor.waitAndDrain(Long.MAX_VALUE);
   >             } catch (InterruptedException e) {
   >                 throw new RuntimeException(e);
   >             }
   >         }).start();
   >         executor.waitAndDrain(Long.MAX_VALUE);
   >         System.out.println("wait not worked");
   >     }
   
   There is no example in Dubbo where waitAndDrain is executed through the same 
threadlessExecutor across multiple threads, so there shouldn't be any issues. I 
don't know if this is a bug.
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit a pull request to fix on your own?
   
   - [X] Yes I am willing to submit a pull request on my own!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to