From: David ‘Bombe’ Roden Date: Wed, 8 Dec 2010 05:41:18 +0000 (+0100) Subject: Add more synchronization. X-Git-Tag: 0.3.2~4 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=8409411dedce0dd2512bb140f2719f4cb281bc76;p=Sone.git Add more synchronization. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Options.java b/src/main/java/net/pterodactylus/sone/core/Options.java index cbe88c8..f77c085 100644 --- a/src/main/java/net/pterodactylus/sone/core/Options.java +++ b/src/main/java/net/pterodactylus/sone/core/Options.java @@ -2,6 +2,7 @@ package net.pterodactylus.sone.core; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -93,7 +94,7 @@ public class Options { private final T defaultValue; /** The current value. */ - private T value; + private volatile T value; /** The option watcher. */ private final List> optionWatchers = new ArrayList>(); @@ -155,10 +156,10 @@ public class Options { } /** Holds all {@link Boolean} {@link Option}s. */ - private final Map> booleanOptions = new HashMap>(); + private final Map> booleanOptions = Collections.synchronizedMap(new HashMap>()); /** Holds all {@link Integer} {@link Option}s. */ - private final Map> integerOptions = new HashMap>(); + private final Map> integerOptions = Collections.synchronizedMap(new HashMap>()); /** * Adds a boolean option.