diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java index a011aa9..f988235 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java @@ -30,7 +30,7 @@ public class TypeUnify { */ public Set> unify(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks) { TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, usedTasks); - ForkJoinPool pool = new ForkJoinPool(); + ForkJoinPool pool = new ForkJoinPool(Runtime.getRuntime().availableProcessors(), ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true); pool.invoke(unifyTask); Set> res = unifyTask.join(); try { @@ -56,7 +56,7 @@ public class TypeUnify { */ public UnifyResultModel unifyAsync(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks) { TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, usedTasks); - ForkJoinPool pool = new ForkJoinPool(); + ForkJoinPool pool = new ForkJoinPool(Runtime.getRuntime().availableProcessors(), ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true); pool.invoke(unifyTask); return ret; } @@ -75,7 +75,7 @@ public class TypeUnify { public UnifyResultModel unifyParallel(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks) { TypeUnifyTask unifyTask = //new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, usedTasks); new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, usedTasks, statistics); - ForkJoinPool pool = new ForkJoinPool(); + ForkJoinPool pool = new ForkJoinPool(Runtime.getRuntime().availableProcessors(), ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true); pool.invoke(unifyTask); Set> res = unifyTask.join(); try { diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index 5368471..9efd728 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(); } @@ -2262,7 +2258,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();