BurningCN opened a new pull request #9096:
URL: https://github.com/apache/dubbo/pull/9096


   ## What is the purpose of the change
   
   The logic of the original code, assuming token=2, there are 10 threads that 
are not satisfied when executing if (token.sum() <= 0), that is, token.sum()> 
0, at this time all execute token.decrement At this time, the value of 
token.sum() becomes a negative number, which is obviously wrong. The judgment 
+decrement is not turned into an atomic operation. Here I reverted to the 
original AtomicInteger to solve this problem.
   
   原有代码的逻辑,假设token=2,有10个线程在执行if (token.sum() <= 0) 的时候都不满足,即token.sum() > 
0,此时都执行token.decrement,token.sum()的值成了负数,显然是不对的,没有将判断+decrement变成原子操作,这里我还原成了原先使用的AtomicInteger来解决这个问题。


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