Object behavior

Chip Morningstar chip@communities.com
Fri, 28 Jul 2000 10:01:47 -0700 (PDT)


>> Well, it is clear that the multithreaded program is broken.  As far as I
>> can see, there are two choices as to why: (1) the Vector documentation is
>> broken, or (2) the Vector specification is broken.
>
>Or (3) whoever included the example code in a multithread program has
>not read the Vector documentation.
>
>From
>http://www.javasoft.com/products/jdk/1.2/docs/api/java/util/Vector.html
>
>The Iterators returned by Vector's iterator and listIterator methods
>are fail-fast: if the Vector is structurally modified at any time
>after the Iterator is created, in any way except through the
>Iterator's own remove or add methods, the Iterator will throw a
>ConcurrentModificationException. Thus, in the face of concurrent
>modification, the Iterator fails quickly and cleanly, rather than
>risking arbitrary, non-deterministic behavior at an undetermined time
>in the future. The Enumerations returned by Vector's elements method
>are not fail-fast. 
>
>Older versions of the documentation may have been broken.

Older versions of the specification were broken. This "fail-fast"
idea is new in Java 1.2, introduced in reaction the very problem Bill
was complaining about.

This actually introduces a whole 'nother can of worms in the problem
of designing and specifying object behavior which this discussion
hasn't even touched on yet: version update.