I'm doing an app in which I have 2 views which extend from SurfaceView, called CanvasView.
I have a left CanvasView, and a right CanvasView. Both these CanvasView instantiate a UIThread, which extends from Thread. The CanvasView itself is passed into the thread like this:
public void surfaceCreated(SurfaceHolder holder) {
uiThread = new UIThread(this);
uiThread.setRunning(true);
uiThread.start();
}
In each CanvasView, onDraw() , I do an access to a list. This list basically consists of a list of things to draw, which are essentially the same on both left and right canvases.
for (CharSequence line : lineList) {
...
..
}
Whenever my app needs to draw the items in lineList, it crashes saying java.util.ConcurrentModificaitonException.
What is the correct way to "share" the Arraylist lineList between the two threads?
Thank you.