Sunday, June 22, 2003 04:23 PM
Even if access to vector methods are synchronized, access to multiple method by multiple threads at the same time is not synchronized. In other words, the synchronization only applies at the method level - not for a series of method invocations on the vector. For example, you could have thread_1 create an iterator, thread_2 add/remove an element, and thread_1 will fail-fast when it tries to access the next element thru the iterator.next() method.
Also, thread_1 can create an iterator, add/remove an element from the vector, then try to iterate over the next element. This too will fail-fast. You don't need mutiple threads to do damage.