Either synchronize things to prevent this (either synchronizing the list or the clearing with drawing), or use a list that is concurrent (http://developer.android.com/reference/java/util/concurrent/package-summary.html) or add an event to run the clearing of the list on the same thread that handles the game ("naturally" preventing the option of a threading issue).
I'm no game developer, but i'd go for the third option. although harder to implement it will be more efficient. On Wednesday, April 24, 2013 6:26:02 PM UTC+3, bob wrote: > > I've been investigating an insidious error in an Android OpenGL game app. > This error was brought to my attention by ACRA. > > I believe that the source of the error is that the code in an onTouchEvent > executes in a different thread than the code > in the OpenGL drawing thread. > > So, basically, the drawing thread was looping thru some enemy ships trying > to draw them. > > Meanwhile, someone pressed the reset button on the game (an onTouchEvent), > and the enemy ship LinkedList got cleared. This clearing occurred while > the drawing thread was looping thru them. Thus an > IndexOutOfBoundsException occurred. > > Anyhow, I guess my question is... how would the professional Android > developer have prevented this? > > Thanks. > > > -- -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

