Add lots of synchronization.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / Core.java
index ab98316..99ebc6d 100644 (file)
@@ -102,13 +102,13 @@ public class Core extends AbstractService {
        private SoneDownloader soneDownloader;
 
        /** The Sone blacklist. */
-       private final Set<Sone> blacklistedSones = new HashSet<Sone>();
+       private final Set<Sone> blacklistedSones = Collections.synchronizedSet(new HashSet<Sone>());
 
        /** The local Sones. */
-       private final Set<Sone> localSones = new HashSet<Sone>();
+       private final Set<Sone> localSones = Collections.synchronizedSet(new HashSet<Sone>());
 
        /** Sone inserters. */
-       private final Map<Sone, SoneInserter> soneInserters = new HashMap<Sone, SoneInserter>();
+       private final Map<Sone, SoneInserter> soneInserters = Collections.synchronizedMap(new HashMap<Sone, SoneInserter>());
 
        /** The Sones’ statuses. */
        private final Map<Sone, SoneStatus> soneStatuses = Collections.synchronizedMap(new HashMap<Sone, SoneStatus>());
@@ -116,13 +116,13 @@ public class Core extends AbstractService {
        /* various caches follow here. */
 
        /** Cache for all known Sones. */
-       private final Map<String, Sone> soneCache = new HashMap<String, Sone>();
+       private final Map<String, Sone> soneCache = Collections.synchronizedMap(new HashMap<String, Sone>());
 
        /** Cache for all known posts. */
-       private final Map<String, Post> postCache = new HashMap<String, Post>();
+       private final Map<String, Post> postCache = Collections.synchronizedMap(new HashMap<String, Post>());
 
        /** Cache for all known replies. */
-       private final Map<String, Reply> replyCache = new HashMap<String, Reply>();
+       private final Map<String, Reply> replyCache = Collections.synchronizedMap(new HashMap<String, Reply>());
 
        /**
         * Creates a new core.