B
Bryan R. Meyer
I've seen quite a few posts on this subject, but none definitively
answer my question. I am iterating over a Hashtable in one thread
while also adding elements to the Hashtable in another thread. On
occasion, a ConcurrentModificationException is being thrown as
expected. The JavaDocs explain that the Iterators are fail-fast and
also mention that Hashtable is synchronized.
Since Hashtable is already synchronized, it doesn't have to be placed
in a synchronization wrapper. If I place a synchronized block around
the code where I do the iteration through the Hashtable, will this
exception still be thrown? If so, what are my options for a
workaround?
Any insight would be appreciated.
Thanks,
Bryan
answer my question. I am iterating over a Hashtable in one thread
while also adding elements to the Hashtable in another thread. On
occasion, a ConcurrentModificationException is being thrown as
expected. The JavaDocs explain that the Iterators are fail-fast and
also mention that Hashtable is synchronized.
Since Hashtable is already synchronized, it doesn't have to be placed
in a synchronization wrapper. If I place a synchronized block around
the code where I do the iteration through the Hashtable, will this
exception still be thrown? If so, what are my options for a
workaround?
Any insight would be appreciated.
Thanks,
Bryan