From: David ‘Bombe’ Roden Date: Fri, 22 May 2009 04:51:48 +0000 (+0200) Subject: Use copy-on-write array list instead of custom synchronization. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=842893c254497c2eac7b90a0a49b4b1bafe94eda;p=jSite2.git Use copy-on-write array list instead of custom synchronization. --- diff --git a/src/net/pterodactylus/util/event/ListenerManager.java b/src/net/pterodactylus/util/event/ListenerManager.java index 333e1eb..26bb3c5 100644 --- a/src/net/pterodactylus/util/event/ListenerManager.java +++ b/src/net/pterodactylus/util/event/ListenerManager.java @@ -19,9 +19,9 @@ package net.pterodactylus.util.event; -import java.util.ArrayList; import java.util.EventListener; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; /** * Helper class for {@link EventListener} management. @@ -30,10 +30,10 @@ import java.util.List; * The type of the event listener * @author David Roden <droden@gmail.com> */ -public class ListenerSupport { +public class ListenerManager { /** The list of registered listeners. */ - private final List listeners = new ArrayList(); + private final List listeners = new CopyOnWriteArrayList(); /** * Adds a listener to the list of registered listeners. @@ -68,9 +68,7 @@ public class ListenerSupport { * @return The list of all listeners */ protected List getListeners() { - synchronized (listeners) { - return new ArrayList(listeners); - } + return listeners; } }