From 796d369b021786649dbda6d5b3aed7a5d3b612a8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 17 Jan 2012 17:03:27 +0100 Subject: [PATCH] Use copy-on-write sets instead of synchronized collections. --- src/main/java/net/pterodactylus/sone/data/Sone.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/data/Sone.java b/src/main/java/net/pterodactylus/sone/data/Sone.java index 901d676..b79dad3 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -21,9 +21,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; -import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.CopyOnWriteArraySet; import java.util.logging.Level; import java.util.logging.Logger; @@ -177,22 +178,22 @@ public class Sone implements Fingerprintable, Comparable { private volatile Client client; /** All friend Sones. */ - private final Set friendSones = Collections.synchronizedSet(new HashSet()); + private final Set friendSones = new CopyOnWriteArraySet(); /** All posts. */ - private final Set posts = Collections.synchronizedSet(new HashSet()); + private final Set posts = new CopyOnWriteArraySet(); /** All replies. */ - private final Set replies = Collections.synchronizedSet(new HashSet()); + private final Set replies = new CopyOnWriteArraySet(); /** The IDs of all liked posts. */ - private final Set likedPostIds = Collections.synchronizedSet(new HashSet()); + private final Set likedPostIds = new CopyOnWriteArraySet(); /** The IDs of all liked replies. */ - private final Set likedReplyIds = Collections.synchronizedSet(new HashSet()); + private final Set likedReplyIds = new CopyOnWriteArraySet(); /** The albums of this Sone. */ - private final List albums = Collections.synchronizedList(new ArrayList()); + private final List albums = new CopyOnWriteArrayList(); /** Sone-specific options. */ private final Options options = new Options(); -- 2.7.4