forked from ChomeNS/chomens-bot-java
fix concurrentfardexception in uh persistent data
it's a really simple fix but i didn't know about executorservices and stuff much back then lol
This commit is contained in:
parent
75599522fd
commit
d6f5314b93
2 changed files with 15 additions and 11 deletions
|
@ -46,5 +46,10 @@
|
||||||
<option name="name" value="maven3" />
|
<option name="name" value="maven3" />
|
||||||
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven4" />
|
||||||
|
<option name="name" value="maven4" />
|
||||||
|
<option name="url" value="https://maven.maxhenkel.de/repository/public" />
|
||||||
|
</remote-repository>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -32,7 +32,6 @@ public class PersistentDataUtilities {
|
||||||
init();
|
init();
|
||||||
|
|
||||||
future = Main.executor.scheduleAtFixedRate(() -> {
|
future = Main.executor.scheduleAtFixedRate(() -> {
|
||||||
// TODO: thread-safe
|
|
||||||
try {
|
try {
|
||||||
if (queue.isEmpty()) return;
|
if (queue.isEmpty()) return;
|
||||||
|
|
||||||
|
@ -91,23 +90,23 @@ public class PersistentDataUtilities {
|
||||||
} catch (IOException ignored) {}
|
} catch (IOException ignored) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void put (String property, JsonElement value) {
|
public static void put (String property, JsonElement value) {
|
||||||
queue.put(property, value);
|
Main.executorService.submit(() -> queue.put(property, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void put (String property, String value) {
|
public static void put (String property, String value) {
|
||||||
queue.put(property, new JsonPrimitive(value));
|
Main.executorService.submit(() -> queue.put(property, new JsonPrimitive(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void put (String property, boolean value) {
|
public static void put (String property, boolean value) {
|
||||||
queue.put(property, new JsonPrimitive(value));
|
Main.executorService.submit(() -> queue.put(property, new JsonPrimitive(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void put (String property, int value) {
|
public static void put (String property, int value) {
|
||||||
queue.put(property, new JsonPrimitive(value));
|
Main.executorService.submit(() -> queue.put(property, new JsonPrimitive(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void put (String property, char value) {
|
public static void put (String property, char value) {
|
||||||
queue.put(property, new JsonPrimitive(value));
|
Main.executorService.submit(() -> queue.put(property, new JsonPrimitive(value)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue