arturobernalg commented on code in PR #234:
URL: https://github.com/apache/jspwiki/pull/234#discussion_r1186747581
##########
jspwiki-event/src/main/java/org/apache/wiki/event/WikiEventManager.java:
##########
@@ -135,8 +135,8 @@ public final class WikiEventManager {
/* The Map of client object to WikiEventDelegate. */
private final Map< Object, WikiEventDelegate > m_delegates = new
HashMap<>();
- /* The Vector containing any preloaded WikiEventDelegates. */
- private final Vector< WikiEventDelegate > m_preloadCache = new Vector<>();
+ /* The List containing any preloaded WikiEventDelegates. */
+ private final List< WikiEventDelegate > m_preloadCache =
Collections.synchronizedList( new ArrayList<>() );
Review Comment:
hi @juanpablo-santos
Another approach you can take to avoid explicitly synchronizing on the list
during iteration is to use a concurrent collection instead of a synchronized
collection.
Instead of using Collections.synchronizedList(), we could use
java.util.concurrent.CopyOnWriteArrayList or
java.util.concurrent.ConcurrentLinkedQueue, both of which are thread-safe and
don't require explicit synchronization during iteration.
WDYT?
--
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]