Changeset 2327 in josm for trunk/src/org/openstreetmap/josm/actions/downloadtasks/PostDownloadHandler.java
- Timestamp:
- 27.10.2009 01:21:32 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/PostDownloadHandler.java
r2322 r2327 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.util.ArrayList; 6 7 import java.util.LinkedHashSet; 8 import java.util.List; 7 9 import java.util.concurrent.Future; 8 10 … … 16 18 public class PostDownloadHandler implements Runnable { 17 19 private DownloadTask task; 18 private Future<?> future;20 private List<Future<?>> futures; 19 21 20 22 /** … … 25 27 public PostDownloadHandler(DownloadTask task, Future<?> future) { 26 28 this.task = task; 27 this.future = future; 29 this.futures = new ArrayList<Future<?>>(); 30 if (future != null) { 31 this.futures.add(future); 32 } 28 33 } 29 34 35 /** 36 * constructor 37 * @param task the asynchronous download task 38 * @param future the future on which the completion of the download task can be synchronized 39 */ 40 public PostDownloadHandler(DownloadTask task, Future<?> ... futures) { 41 this.task = task; 42 this.futures = new ArrayList<Future<?>>(); 43 if (futures == null) return; 44 for (Future<?> future: futures) { 45 this.futures.add(future); 46 } 47 } 48 49 50 /** 51 * constructor 52 * @param task the asynchronous download task 53 * @param future the future on which the completion of the download task can be synchronized 54 */ 55 public PostDownloadHandler(DownloadTask task, List<Future<?>> futures) { 56 this.task = task; 57 this.futures = new ArrayList<Future<?>>(); 58 if (futures == null) return; 59 this.futures.addAll(futures); 60 } 61 30 62 public void run() { 31 // wait for the download task to complete 63 // wait for all downloads task to finish (by waiting for the futures 64 // to return a value) 32 65 // 33 try { 34 future.get(); 35 } catch(Exception e) { 36 e.printStackTrace(); 37 return; 66 for (Future<?> future: futures) { 67 try { 68 future.get(); 69 } catch(Exception e) { 70 e.printStackTrace(); 71 return; 72 } 38 73 } 39 74
Note: See TracChangeset
for help on using the changeset viewer.
