Fail-fast : failure condition is detected before damage can be done
ArrayList has a modCount : any operation of modification can raise modCount (add, remove,clear.....).
When the Thread found the modCount != expectedModCount ----> a fail-fast
How to avoid : use thread safe containers (CopyOnWriterArrayList -> all add, remove operations are realized by copy the array).
No comments:
Post a Comment