[android-developers] Re: ConcurrentModificationException from Handler

2011-01-17 Thread AC
Perhaps I'm sending the message from the service to the activity incorrectly, and syncMarkers() ends up getting called from the service's thread? If so, would anyone have any advice on the correct way to send the message? -- You received this message because you are subscribed to the Google

Re: [android-developers] Re: ConcurrentModificationException from Handler

2011-01-17 Thread Kumar Bibek
This exception generally occurs, if you are iterating through it and changing it simultaneously. *Note that this implementation is not synchronized.* If multiple threads access this map concurrently, and at least one of the threads modifies the map structurally, it *must* be synchronized

Re: [android-developers] Re: ConcurrentModificationException from Handler

2011-01-17 Thread Kostya Vasilyev
First, a link to docs: http://download.oracle.com/javase/1.4.2/docs/api/java/util/ConcurrentModificationException.html I can see several possible causes for this, and you should get a more detailed stack trace (more than inside syncMarkers): 1 - You have two threads concurrently accessing the

[android-developers] Re: ConcurrentModificationException from Handler

2011-01-17 Thread AC
I'm afraid that didn't help. I now have: public class MapViewActivity extends MapActivity { private static MapString, Object markers = Collections.synchronizedMap( new HashMapString, Object() ); and the problem still occurs. -- You received this message because you are subscribed to the

Re: [android-developers] Re: ConcurrentModificationException from Handler

2011-01-17 Thread Kumar Bibek
There might be other reasons to the problem. Kostya has mentioned all the details regarding the exception. :) Kumar Bibek http://techdroid.kbeanie.com http://www.kbeanie.com On Mon, Jan 17, 2011 at 2:32 PM, AC alistair.cunning...@gmail.com wrote: I'm afraid that didn't help. I now have:

Re: [android-developers] Re: ConcurrentModificationException from Handler

2011-01-17 Thread Kostya Vasilyev
Well, I don't know if that covered *all* the possibilities, but that's a place to start :) 2011/1/17 Kumar Bibek coomar@gmail.com There might be other reasons to the problem. Kostya has mentioned all the details regarding the exception. :) Kumar Bibek http://techdroid.kbeanie.com

[android-developers] Re: ConcurrentModificationException from Handler

2011-01-17 Thread AC
On Jan 17, 5:00 pm, Kostya Vasilyev kmans...@gmail.com wrote: 2 - As described in the link above, code that is trying to remove elements from a collection while iterating, for example: for (Item i : myHashMap.values()) {    if (some condition) {       myHashMap.remove(i.key);    } }

[android-developers] Re: ConcurrentModificationException from Handler

2011-01-17 Thread AC
After changing to iterator.remove() rather than removing from the Map, the problem went away. Thank you very much! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To

Re: [android-developers] Re: ConcurrentModificationException from Handler

2011-01-17 Thread Kostya Vasilyev
Cool. I would also recommend that you change your code to send new data in the message, like I described above. If your netwoking code runs on a separate thread - which it should be - then that global is like a dog waiting to bite you when you least expect. -- Kostya 2011/1/17 AC