1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

Merge pull request #282 from muzuro/master

fix memory leak
This commit is contained in:
Stefan Schröder 2016-09-29 12:42:10 +02:00 committed by GitHub
commit 915b2969a3

View file

@ -629,13 +629,21 @@ public class Jsprit {
});
}
if (es != null) {
Runtime.getRuntime().addShutdownHook(new Thread() {
final Thread hook = new Thread() {
public void run() {
if (!es.isShutdown()) {
System.err.println("shutdowHook shuts down executorService");
es.shutdown();
}
}
};
Runtime.getRuntime().addShutdownHook(hook);
vra.addListener(new AlgorithmEndsListener() {
@Override
public void informAlgorithmEnds(VehicleRoutingProblem aProblem,
Collection<VehicleRoutingProblemSolution> aSolutions) {
Runtime.getRuntime().removeShutdownHook(hook);
}
});
}
}