mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
move hook stuff to if - related to #282
This commit is contained in:
parent
915b2969a3
commit
5ef8ba12e9
1 changed files with 16 additions and 13 deletions
|
|
@ -619,33 +619,36 @@ public class Jsprit {
|
|||
|
||||
private void handleExecutorShutdown(VehicleRoutingAlgorithm vra) {
|
||||
if (setupExecutorInternally) {
|
||||
vra.addListener(new AlgorithmEndsListener() {
|
||||
|
||||
@Override
|
||||
public void informAlgorithmEnds(VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) {
|
||||
es.shutdown();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
if (es != null) {
|
||||
final Thread hook = new Thread() {
|
||||
public void run() {
|
||||
if (!es.isShutdown()) {
|
||||
System.err.println("shutdowHook shuts down executorService");
|
||||
System.err.println("shutdownHook shuts down executorService");
|
||||
es.shutdown();
|
||||
}
|
||||
}
|
||||
};
|
||||
Runtime.getRuntime().addShutdownHook(hook);
|
||||
vra.addListener(new AlgorithmEndsListener() {
|
||||
|
||||
@Override
|
||||
public void informAlgorithmEnds(VehicleRoutingProblem aProblem,
|
||||
Collection<VehicleRoutingProblemSolution> aSolutions) {
|
||||
public void informAlgorithmEnds(VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) {
|
||||
es.shutdown();
|
||||
Runtime.getRuntime().removeShutdownHook(hook);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
// if (es != null) {
|
||||
//
|
||||
// Runtime.getRuntime().addShutdownHook(hook);
|
||||
// vra.addListener(new AlgorithmEndsListener() {
|
||||
// @Override
|
||||
// public void informAlgorithmEnds(VehicleRoutingProblem aProblem,
|
||||
// Collection<VehicleRoutingProblemSolution> aSolutions) {
|
||||
// Runtime.getRuntime().removeShutdownHook(hook);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
|
||||
String getProperty(String key) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue