From 842893c254497c2eac7b90a0a49b4b1bafe94eda Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 22 May 2009 06:51:48 +0200 Subject: [PATCH] Use copy-on-write array list instead of custom synchronization. --- src/net/pterodactylus/util/event/ListenerManager.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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; } } -- 2.7.4