- Timestamp:
- 2021-03-24T08:16:29+01:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java
r17635 r17654 81 81 private boolean recurseDownAppended = true; 82 82 83 private ExecutorService exec; 84 83 85 /** 84 86 * Constructs a {@code MultiFetchServerObjectReader}. … … 320 322 int threadsNumber = Config.getPref().getInt("osm.download.threads", OsmApi.MAX_DOWNLOAD_THREADS); 321 323 threadsNumber = Utils.clamp(threadsNumber, 1, OsmApi.MAX_DOWNLOAD_THREADS); 322 final ExecutorServiceexec = Executors.newFixedThreadPool(324 exec = Executors.newFixedThreadPool( 323 325 threadsNumber, Utils.newThreadFactory(getClass() + "-%d", Thread.NORM_PRIORITY)); 324 326 CompletionService<FetchResult> ecs = new ExecutorCompletionService<>(exec); 325 327 List<Future<FetchResult>> jobs = new ArrayList<>(); 326 while (!toFetch.isEmpty() ) {328 while (!toFetch.isEmpty() && !isCanceled()) { 327 329 jobs.add(ecs.submit(new Fetcher(type, extractIdPackage(toFetch), progressMonitor))); 328 330 } … … 358 360 } 359 361 } 362 exec = null; 360 363 } 361 364 … … 706 709 } 707 710 } 711 712 @Override 713 public void cancel() { 714 super.cancel(); 715 if (exec != null) 716 exec.shutdownNow(); 717 } 708 718 }
Note:
See TracChangeset
for help on using the changeset viewer.