diff --git a/ArtificialAutism/src/main/java/FunctionLayer/Datahandler.java b/ArtificialAutism/src/main/java/FunctionLayer/Datahandler.java index 9971f3a7..ec643655 100644 --- a/ArtificialAutism/src/main/java/FunctionLayer/Datahandler.java +++ b/ArtificialAutism/src/main/java/FunctionLayer/Datahandler.java @@ -266,6 +266,7 @@ public class Datahandler { } } + //synchronized public synchronized void updateMatrixes() { refreshMatrixFromDB = false; if (stopwatch1.elapsed(TimeUnit.SECONDS) >= EXPIRE_TIME_IN_SECONDS1) { @@ -280,14 +281,8 @@ public class Datahandler { LinkedHashMap> LHMSMXLocal = lHMSMX; int ij2 = 0; for (String str : stringCachelocal.values()) { - boolean updatepresent = false; - for (String strlocal : LHMSMXLocal.keySet()) { - if (strlocal.equals(str)) { - updatepresent = true; - break; - } - } - if (!updatepresent) { + LinkedHashMap orDefault = LHMSMXLocal.getOrDefault(str, null); + if (orDefault == null) { selectUpdate = ij2; break; } @@ -308,25 +303,17 @@ public class Datahandler { boolean present = false; LinkedHashMap orDefault = lHMSMX.getOrDefault(getStringCacheStr, null); if (orDefault != null) { - Iterator strDefaultsItr = orDefault.keySet().iterator(); - while (strDefaultsItr.hasNext()) { - String strkey = strDefaultsItr.next(); - if (strkey.equals(str1)) { - present = true; - break; - } + Double orDefault1 = orDefault.getOrDefault(str1, null); + if (orDefault1 != null) { + present = true; } } if (!present) { orDefault = lHMSMX.getOrDefault(str1, null); if (orDefault != null) { - Iterator strDefaultsItr = orDefault.keySet().iterator(); - while (strDefaultsItr.hasNext()) { - String strkey = strDefaultsItr.next(); - if (strkey.equals(getStringCacheStr)) { - present = true; - break; - } + Double orDefault1 = orDefault.getOrDefault(getStringCacheStr, null); + if (orDefault1 != null) { + present = true; } } } @@ -360,16 +347,19 @@ public class Datahandler { matrixUpdateList.put(matrixUpdateList.size() + 1, SMX); } }); - try { - if (!matrixUpdateList.isEmpty()) { - DataMapper.insertSementicMatrixes(matrixUpdateList); - System.out.println("finished datamapper semetic insert"); + new Thread(() -> { + try { + if (!matrixUpdateList.isEmpty()) { + DataMapper.insertSementicMatrixes(matrixUpdateList); + System.out.println("finished datamapper semetic insert"); + } + } catch (CustomError ex) { + Logger.getLogger(Datahandler.class + .getName()).log(Level.SEVERE, null, ex); } - } catch (CustomError ex) { - Logger.getLogger(Datahandler.class - .getName()).log(Level.SEVERE, null, ex); - } + }).start(); } + } public synchronized void checkIfUpdateStrings(boolean hlStatsMsg) throws CustomError {