I m writing an app containing an asyncTask which continuously (every seconds or so) adds a value to an ArrayList<Float> (declared static).
The value is a measure in inches that I want to plot.
In order to do that I have implemented a solution with OpenGL ES.
And every time I add a new value my AsynTask calls the requestRender() method.
Then the drawRenderer() take the ArrayList<Float> and draw lines with it.
At this point everything works perfectly fine.
I also want that the user can pinch-zoom and move the plot. So I have a TouchsurfaceView which also calls requestRender() when needed.
Most of the time it works, but time to time I get an error because of concurrent requests for the ArrayList<Float> (almost sure of that).
Any ideas How can I solve this ? I see lock and synchronized stuff, but can t find how to properly use them for my case.
Thanks for reading me.
put all the updates to the static variable in a synchronized static method and use only that for making updates.