From dd62d8d6b9da4e3985f1056146f6855cfdbbdc71 Mon Sep 17 00:00:00 2001 From: NoName11234 <47484268+NoName11234@users.noreply.github.com> Date: Thu, 25 Apr 2024 16:50:14 +0200 Subject: [PATCH] removed thread counter variables from typeunifytask --- .../typeinference/unify/TypeUnifyTask.java | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index ff9e6cd..c24632d 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -74,11 +74,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; @@ -179,8 +177,7 @@ public class TypeUnifyTask extends RecursiveTask>> { this.parallel = parallel; this.logFile = logFile; this.log = log; - - noOfThread++; + totalnoOfThread++; //writeLog("thNo1 " + thNo); thNo = totalnoOfThread; @@ -269,7 +266,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(); } @@ -924,7 +920,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); @@ -984,7 +980,6 @@ public class TypeUnifyTask extends RecursiveTask>> { /* FORK ANFANG */ synchronized (this) { writeLog("wait "+ forkOrig.thNo); - noOfThread--; res = forkOrig.join(); synchronized (usedTasks) { if (this.myIsCancelled()) { @@ -1004,7 +999,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()) { @@ -1026,7 +1020,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); @@ -1085,7 +1079,6 @@ public class TypeUnifyTask extends RecursiveTask>> { /* FORK ANFANG */ synchronized (this) { writeLog("wait "+ forkOrig.thNo); - noOfThread--; res = forkOrig.join(); synchronized (usedTasks) { if (this.myIsCancelled()) { @@ -1105,7 +1098,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()) { @@ -1127,7 +1119,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); @@ -1171,7 +1163,6 @@ public class TypeUnifyTask extends RecursiveTask>> { /* FORK ANFANG */ synchronized (this) { writeLog("wait "+ forkOrig.thNo); - noOfThread--; res = forkOrig.join(); synchronized (usedTasks) { if (this.myIsCancelled()) { @@ -1190,7 +1181,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()) { @@ -2612,7 +2602,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();