Thursday, May 14, 2009

ConcurrentModificationException

While iterating over the List, or anything which implements iteratable, we cannot modify the contents of that particular collection. Not a surprise, but today while implementing iteratable (@ work) I din't know how to achieve this. BTW, why do I need to throw this exception ?? do I care ?? should I not just use object locking ?? I guess all of us know the reason, object state in multithreaded applications & performance. Anyways, I think below implementation looks decent enough:

No comments: