diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index d2c1fc6b2..968eaccad 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Map.Entry; import java.util.Optional; import java.util.Set; +import java.util.concurrent.ForkJoinPool; import java.util.concurrent.RecursiveTask; import java.util.function.BiFunction; import java.util.function.BinaryOperator; @@ -79,11 +80,9 @@ public class TypeUnifyTask extends RecursiveTask>> { * Fuer die Threads */ UnifyResultModel urm; - protected static int noOfThread = 0; private static int totalnoOfThread = 0; int thNo; protected boolean one = false; - Integer MaxNoOfThreads = 128; public static final String rootDirectory = System.getProperty("user.dir")+"/test/logFiles/"; Writer logFile; @@ -184,8 +183,7 @@ public class TypeUnifyTask extends RecursiveTask>> { this.parallel = parallel; this.logFile = logFile; this.log = log; - - noOfThread++; + totalnoOfThread++; //writeLog("thNo1 " + thNo); thNo = totalnoOfThread; @@ -274,7 +272,6 @@ public class TypeUnifyTask extends RecursiveTask>> { .filter(x -> x.size()>1) .collect(Collectors.toCollection(ArrayList::new)); Set> res = unify(neweq, remainingOderconstraints, fc, parallel, rekTiefeField, new HashSet<>()); - noOfThread--; try { logFile.close(); } @@ -929,7 +926,7 @@ public class TypeUnifyTask extends RecursiveTask>> { /* Wenn parallel gearbeitet wird, wird je nach Varianz ein neuer Thread * gestartet, der parallel weiterarbeitet. */ - if(parallel && (variance == 1) && noOfThread <= MaxNoOfThreads) { + if(parallel && (variance == 1)) { Set forks = new HashSet<>(); Set newEqOrig = new HashSet<>(eq); Set> newElemsOrig = new HashSet<>(elems); @@ -989,7 +986,6 @@ public class TypeUnifyTask extends RecursiveTask>> { /* FORK ANFANG */ synchronized (this) { writeLog("wait "+ forkOrig.thNo); - noOfThread--; res = forkOrig.join(); synchronized (usedTasks) { if (this.myIsCancelled()) { @@ -1009,7 +1005,6 @@ public class TypeUnifyTask extends RecursiveTask>> { forks.forEach(x -> writeLog("wait: " + x.thNo)); for(TypeUnify2Task fork : forks) { synchronized (this) { - noOfThread--; Set> fork_res = fork.join(); synchronized (usedTasks) { if (this.myIsCancelled()) { @@ -1031,7 +1026,7 @@ public class TypeUnifyTask extends RecursiveTask>> { } //noOfThread++; } else { - if(parallel && (variance == -1) && noOfThread <= MaxNoOfThreads) { + if(parallel && (variance == -1)) { Set forks = new HashSet<>(); Set newEqOrig = new HashSet<>(eq); Set> newElemsOrig = new HashSet<>(elems); @@ -1090,7 +1085,6 @@ public class TypeUnifyTask extends RecursiveTask>> { /* FORK ANFANG */ synchronized (this) { writeLog("wait "+ forkOrig.thNo); - noOfThread--; res = forkOrig.join(); synchronized (usedTasks) { if (this.myIsCancelled()) { @@ -1110,7 +1104,6 @@ public class TypeUnifyTask extends RecursiveTask>> { forks.forEach(x -> writeLog("wait: " + x.thNo)); for(TypeUnify2Task fork : forks) { synchronized (this) { - noOfThread--; Set> fork_res = fork.join(); synchronized (usedTasks) { if (this.myIsCancelled()) { @@ -1132,7 +1125,7 @@ public class TypeUnifyTask extends RecursiveTask>> { } //noOfThread++; } else { - if(parallel && (variance == 2) && noOfThread <= MaxNoOfThreads) { + if(parallel && (variance == 2)) { writeLog("var2einstieg"); Set forks = new HashSet<>(); Set newEqOrig = new HashSet<>(eq); @@ -1176,7 +1169,6 @@ public class TypeUnifyTask extends RecursiveTask>> { /* FORK ANFANG */ synchronized (this) { writeLog("wait "+ forkOrig.thNo); - noOfThread--; res = forkOrig.join(); synchronized (usedTasks) { if (this.myIsCancelled()) { @@ -1195,7 +1187,6 @@ public class TypeUnifyTask extends RecursiveTask>> { forks.forEach(x -> writeLog("wait: " + x.thNo)); for(TypeUnify2Task fork : forks) { synchronized (this) { - noOfThread--; Set> fork_res = fork.join(); synchronized (usedTasks) { if (this.myIsCancelled()) { @@ -2617,7 +2608,6 @@ public class TypeUnifyTask extends RecursiveTask>> { if (log && finalresult) { try { logFile.write("Thread no.:" + thNo + "\n"); - logFile.write("noOfThread:" + noOfThread + "\n"); logFile.write("parallel:" + parallel + "\n"); logFile.write(str+"\n\n"); logFile.flush();