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:
parent
ce3d37d91c
commit
c1a5f82ba1
1 changed files with 9 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue