T run this on the Swing EDT or JOSM will freeze future.get(); // waits for the dowload task to complete The following example uses a pattern which is better suited if a task is launched from the Swing EDT:
final Future<?> future = task.download(...); Runnable runAfterTask = new Runnable() { public void run() { // this is not strictly necessary because of the type of executor service // Main.worker is initialized with, but it doesn't harm either // future.get(); // wait for the download task to complete doSomethingAfterTheTaskCompleted(); } } Main.worker.submit(runAfterTask);
@param newLayer true, if the data is to be downloaded into a new layer. If false, the taskselects one of the existing layers as download layer, preferably the active layer.
@param downloadArea the area to download
@param progressMonitor the progressMonitor
@return the future representing the asynchronous task