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

fix memory leak

This commit is contained in:
muzuro 2016-09-28 12:06:01 +03:00
parent ce3d37d91c
commit c1a5f82ba1

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);
}
});
}
}