From de0d9b11e74e6e9982976d480deec38a20b978f8 Mon Sep 17 00:00:00 2001 From: Mason-Lam <97353903+Mason-Lam@users.noreply.github.com> Date: Thu, 30 Jun 2022 08:13:13 -0700 Subject: [PATCH] Multi Threading fix? Take a sledgehammer and make every method synchronized because I do not feel like learning how multi-threading works so make everything thread safe. A perfect solution. 50% chance this gets reverted. Although the next solution is just make every variable volatile and I don't know where I'm going with this description. --- src/main/java/frc/team3128/ConstantsInt.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/team3128/ConstantsInt.java b/src/main/java/frc/team3128/ConstantsInt.java index 0b9efe6b..810bd379 100644 --- a/src/main/java/frc/team3128/ConstantsInt.java +++ b/src/main/java/frc/team3128/ConstantsInt.java @@ -83,7 +83,7 @@ private static void initTempConstants() { } //Change the value of a constant - public static void updateConstant(String category, String name, String value) throws IllegalArgumentException { + public static synchronized void updateConstant(String category, String name, String value) throws IllegalArgumentException { String callerClass = Thread.currentThread().getStackTrace()[2].getClassName(); if(!callerClass.equals("frc.team3128.common.narwhaldashboard.NarwhalDashboard")) throw new IllegalArgumentException("Caller class is not valid!"); Class clazz = categories.get(category); //Get the specified Constant class @@ -132,12 +132,12 @@ private static Object parseData(String value) { } //Return each field of a constants class - public static ArrayList getConstantInfo(String category) { + public static synchronized ArrayList getConstantInfo(String category) { return editConstants.get(category); } //Make a constant editable - public static void addConstant(String category, String name) throws IllegalArgumentException{ + public static synchronized void addConstant(String category, String name) throws IllegalArgumentException{ try { Field field = categories.get(category).getField(name); try {