Switch to CountDownLatch
This commit is contained in:
@@ -24,7 +24,7 @@ import java.util.HashMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
@@ -72,12 +72,12 @@ public class TaskList extends Thread {
|
|||||||
private class Invoker implements Runnable {
|
private class Invoker implements Runnable {
|
||||||
|
|
||||||
Task task;
|
Task task;
|
||||||
Set<Invoker> s;
|
CountDownLatch latch;
|
||||||
AtomicBoolean bool;
|
AtomicBoolean bool;
|
||||||
|
|
||||||
public Invoker(Task task, Set<Invoker> ss, AtomicBoolean bool) {
|
public Invoker(Task task, CountDownLatch latch, AtomicBoolean bool) {
|
||||||
this.task = task;
|
this.task = task;
|
||||||
s = ss;
|
this.latch = latch;
|
||||||
this.bool = bool;
|
this.bool = bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ public class TaskList extends Thread {
|
|||||||
public void run() {
|
public void run() {
|
||||||
if (!executeTask(task))
|
if (!executeTask(task))
|
||||||
bool.set(false);
|
bool.set(false);
|
||||||
s.remove(this);
|
latch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -99,20 +99,16 @@ public class TaskList extends Thread {
|
|||||||
return true;
|
return true;
|
||||||
this.totTask += c.size();
|
this.totTask += c.size();
|
||||||
AtomicBoolean bool = new AtomicBoolean(true);
|
AtomicBoolean bool = new AtomicBoolean(true);
|
||||||
Set<Invoker> runningThread = Collections.synchronizedSet(new HashSet<Invoker>());
|
CountDownLatch counter = new CountDownLatch(c.size());
|
||||||
for (Task t2 : c) {
|
for (Task t2 : c) {
|
||||||
t2.setParallelExecuting(true);
|
t2.setParallelExecuting(true);
|
||||||
Invoker thread = new Invoker(t2, runningThread, bool);
|
Invoker thread = new Invoker(t2, counter, bool);
|
||||||
runningThread.add(thread);
|
|
||||||
invokers.add(thread);
|
invokers.add(thread);
|
||||||
if (!EXECUTOR_SERVICE.isShutdown() && !EXECUTOR_SERVICE.isTerminated())
|
if (!EXECUTOR_SERVICE.isShutdown() && !EXECUTOR_SERVICE.isTerminated())
|
||||||
futures.put(thread, EXECUTOR_SERVICE.submit(thread));
|
futures.put(thread, EXECUTOR_SERVICE.submit(thread));
|
||||||
}
|
}
|
||||||
while (!runningThread.isEmpty())
|
|
||||||
try {
|
try {
|
||||||
if (this.isInterrupted())
|
counter.await();
|
||||||
return false;
|
|
||||||
Thread.sleep(1);
|
|
||||||
} catch (InterruptedException ignore) {
|
} catch (InterruptedException ignore) {
|
||||||
}
|
}
|
||||||
return bool.get();
|
return bool.get();
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ if (buildnumber == null)
|
|||||||
|
|
||||||
def versionroot = System.getenv("VERSION_ROOT")
|
def versionroot = System.getenv("VERSION_ROOT")
|
||||||
if (versionroot == null)
|
if (versionroot == null)
|
||||||
versionroot = "0.8.6"
|
versionroot = "0.8.7"
|
||||||
|
|
||||||
String mavenGroupId = 'HMCSM'
|
String mavenGroupId = 'HMCSM'
|
||||||
String mavenVersion = versionroot + '.' + buildnumber
|
String mavenVersion = versionroot + '.' + buildnumber
|
||||||
|
|||||||
Reference in New Issue
Block a user