You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2021/10/13 14:45:58 UTC

[GitHub] [activemq] cshannon commented on pull request #720: [AMQ-8400] Add synchronization handling around synchronizations to pr…

cshannon commented on pull request #720:
URL: https://github.com/apache/activemq/pull/720#issuecomment-942380306


   I'm not really a fan of this solution, there's a couple other approaches you could take.
   
   First, If you are going to copy anyways then why not just use a CopyOnWriteArrayList and not have to synchronize and do all the manual copying?
   
   Another option that might be better is just do what JB said and synchronized the list. Then you also need to synchronize when iterating as well and this would avoid the expensive copy as wrapping with with Synchronized doesn't make iterating thread safe. It should be rare for 2 threads to be touching the Transaction object usually so synchronizing should be fine most of the time.
   
   You also may be able to find another collection type that is concurrent that could be used but for list implementations there aren't really any.


-- 
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: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org