poorbarcode commented on code in PR #19585:
URL: https://github.com/apache/pulsar/pull/19585#discussion_r1122539456


##########
pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/GrowableArrayBlockingQueue.java:
##########
@@ -127,6 +132,13 @@ public boolean offer(T e) {
 
     @Override
     public void put(T e) {
+        if (terminated){

Review Comment:
   > but it cannot be guaranteed under the execution order listed by me
   
   I do not think so.
   
   After the thread which executed `terminal` get the lock `tailLock`, it means 
the last "Execute the remaining logic of the put method" has finished.
   
   <img width="851" alt="截屏2023-03-02 10 32 28" 
src="https://user-images.githubusercontent.com/25195800/222316017-4f288ab2-a876-48b3-a7bd-b73f05679517.png";>
   
   The `terminate-thread` can only get the lock after the lock is released by 
the `put-thread`
   
   <img width="508" alt="截屏2023-03-02 10 35 03" 
src="https://user-images.githubusercontent.com/25195800/222316371-8c8b4ba0-8adc-4e63-8abc-d4761e787b1a.png";>
   
   



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