From 619f4ab69fe132af96653b366a3bad67784d5260 Mon Sep 17 00:00:00 2001 From: Cookiebowser <lucas.doering@live.de> Date: Thu, 14 Jul 2022 16:34:58 +0200 Subject: [PATCH] changed states-set to ConcurrentHashSet in JavaTemplate --- .../hhu/stups/codegenerator/JavaTemplate.stg | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main/resources/de/hhu/stups/codegenerator/JavaTemplate.stg b/src/main/resources/de/hhu/stups/codegenerator/JavaTemplate.stg index 66fcf78ed..324401c4f 100644 --- a/src/main/resources/de/hhu/stups/codegenerator/JavaTemplate.stg +++ b/src/main/resources/de/hhu/stups/codegenerator/JavaTemplate.stg @@ -15,6 +15,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.Future; import java.util.concurrent.Executors; @@ -1187,7 +1188,7 @@ private static class ModelChecker { private final boolean isDebug; private final LinkedList\<<machine>\> unvisitedStates = new LinkedList\<>(); - private final Set\<<machine>\> states = new HashSet\<>(); + private final Set\<<machine>\> states = ConcurrentHashMap.newKeySet(); private AtomicInteger transitions = new AtomicInteger(0); private ThreadPoolExecutor threadPool; private Object waitLock = new Object(); @@ -1485,17 +1486,14 @@ private void modelCheckMultiThreaded() { Set\<<machine>\> nextStates = generateNextStates(state); nextStates.forEach(nextState -> { - synchronized (states) { - if(!states.contains(nextState)) { - states.add(nextState); - synchronized (unvisitedStates) { - unvisitedStates.add(nextState); - } - if(states.size() % 50000 == 0 && isDebug) { - System.out.println("VISITED STATES: " + states.size()); - System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); - System.out.println("-------------------"); - } + if(states.add(nextState)) { + synchronized (unvisitedStates) { + unvisitedStates.add(nextState); + } + if(states.size() % 50000 == 0 && isDebug) { + System.out.println("VISITED STATES: " + states.size()); + System.out.println("EVALUATED TRANSITIONS: " + transitions.get()); + System.out.println("-------------------"); } } }); -- GitLab