You are modifying the set while you are iterating over it. This has nothing to do with multi-threading.
Try something like... Set<WidgetTask> tasks = widgetTaskSet.getAllTasks(); for(WidgetTask task: tasks) { task.execute(); } tasks.clear(); There are plenty more options too. Just don't modify the collection while iterating over it. Jason On Mon, Jul 13, 2009 at 3:12 PM, Paul Sabou <paul.sa...@gmail.com> wrote: > > Hi, > > While running in hosted mode with GWT 1.6.4 I receive the following > error : > > [ERROR] Uncaught exception escaped > java.util.ConcurrentModificationException: null > at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793) > at java.util.HashMap$ValueIterator.next(HashMap.java:822) > ....... > > > I tracked down the "offending block" : > ---- BEGIN CODE ---- > > Iterator<WidgetTask> taskIterator = > widgetTaskSet > .getAllTasks().iterator(); > > // Execute Each Task > while (taskIterator.hasNext()) { > WidgetTask dwt = taskIterator.next(); > // Delete the task > widgetTaskSet.deleteTask(dwt); > > // Execute the task goes here > > } > > > ---- END CODE ---- > > It seems that this block of code is executed somehow "in paralel" in > hosted mode so that while some "thread" iterates over the structure, > another one adds or deletes things from it. This behaviour is somewhat > natural in any event driven app (including my own). > > I know that browsers are not multi-threaded, but the above scenario is > also possible in a browser because my application does asyncronuous > requests to the server. > > Is there any way to syncronise the block/data structure so that this > doesn't happen anymore? > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---