How to get previous element from collection and correctly synchronize threads?
I'm trying to do something like this:
I'm getting this error:
Vector myRays = new Vector<Ray>();
if (myRays.size() > 0)
Iterator<Ray> iter = myRays.iterator();
//myRays.remove(myRays.elementAt(myRays.size()-1));//here I'm getting an error
Exception in thread "Thread-5" java.util.ConcurrentModificationException
I suspect that some of my methods should be synchronized (those which has direct access to myRays object) and I've made them synchronized but without any results.
Thanks for any help.