From 8409411dedce0dd2512bb140f2719f4cb281bc76 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 8 Dec 2010 06:41:18 +0100 Subject: [PATCH] Add more synchronization. --- src/main/java/net/pterodactylus/sone/core/Options.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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. -- 2.7.4