commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Pitts <>
Subject Re: [JCS] ConcurrentModificationException
Date Wed, 25 Jan 2012 23:31:49 GMT
On 1/25/12 4:26 AM, Thomas Muller wrote:
> Hi,
> I don't know JCS at all, but the exception you get is the result of 
> one thread updating a collection (in your case a HashMap) whilst 
> another thread is iterating it. 
Actually, that exception can (and does) happen in single threaded 
applications, although that might not be the case here.
> This would happen even if the Map was decorated using the 
> Collections.synchronizedMap( myMap ) facility. To allow /true/ 
> concurrent access/updates to a Map, the 
> java.util.concurrent.ConcurrentHashMap (or another class implementing 
> the ConcurrentMap) must be deployed.
Using ConcurrentHashMap may be a heavy weight solution to a simple problem.

In general, if you are serializing an object graph, you should not be 
modifying that graph concurrently.

> May there is a way you can force JCS to use another Map implementation 
> than HashMap? Some factory method somewhere?
This looks like the HashMap is in the Object Model, unrelated to JCS.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message