[collections] ConcurentModificationException-free iterator ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[collections] ConcurentModificationException-free iterator ?

Nicolas De Loof-3

Is they're any way to get an Iterator on a collection (in my case a map)
when other trheads are adding datas, and not get
ConcurrentModificationException ?

I've tested some "freeze" solution to lock put() method during my
iteration, but as it seems to work (?) it is neither standard nor fully
tested.

Is they're any "best practice" for such a case ?

Nico.


This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,  distribute, or use this message or any part thereof. If you receive this  message in error, please notify the sender immediately and delete all  copies of this message.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [collections] ConcurentModificationException-free iterator ?

Ronald Klop-2
1. You can copy the Map before getting the iterator. (needs some locking  
also)
2. In Java 5 is a ConcurrentHashMap.

On Fri, 10 Jun 2005 17:12:05 +0200, Nicolas De Loof  
<[hidden email]> wrote:

>
> Is they're any way to get an Iterator on a collection (in my case a map)  
> when other trheads are adding datas, and not get  
> ConcurrentModificationException ?
>
> I've tested some "freeze" solution to lock put() method during my  
> iteration, but as it seems to work (?) it is neither standard nor fully  
> tested.
>
> Is they're any "best practice" for such a case ?
>
> Nico.
>
>
> This message contains information that may be privileged or confidential  
> and is the property of the Capgemini Group. It is intended only for the  
> person to whom it is addressed. If you are not the intended recipient,  
> you are not authorized to read, print, retain, copy, disseminate,  
> distribute, or use this message or any part thereof. If you receive  
> this  message in error, please notify the sender immediately and delete  
> all  copies of this message.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>



--
  Ronald Klop
  Amsterdam, The Netherlands

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [collections] ConcurentModificationException-free iterator ?

Nicolas De Loof-3

JSR166 Backport library
(http://www.mathcs.emory.edu/dcl/util/backport-util-concurrent/)
includes a JDK 1.4 version of ConcurrentHashMap. Sounds great for what I
need.

Thanks !

Nico.

Ronald Klop a ?crit :

> 1. You can copy the Map before getting the iterator. (needs some
> locking  also)
> 2. In Java 5 is a ConcurrentHashMap.
>
> On Fri, 10 Jun 2005 17:12:05 +0200, Nicolas De Loof  
> <[hidden email]> wrote:
>
>>
>> Is they're any way to get an Iterator on a collection (in my case a
>> map)  when other trheads are adding datas, and not get  
>> ConcurrentModificationException ?
>>
>> I've tested some "freeze" solution to lock put() method during my  
>> iteration, but as it seems to work (?) it is neither standard nor
>> fully  tested.
>>
>> Is they're any "best practice" for such a case ?
>>
>> Nico.
>>
>>
>> This message contains information that may be privileged or
>> confidential  and is the property of the Capgemini Group. It is
>> intended only for the  person to whom it is addressed. If you are not
>> the intended recipient,   you are not authorized to read, print,
>> retain, copy, disseminate,   distribute, or use this message or any
>> part thereof. If you receive  this  message in error, please notify
>> the sender immediately and delete  all  copies of this message.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
>
>

This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,  distribute, or use this message or any part thereof. If you receive this  message in error, please notify the sender immediately and delete all  copies of this message.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]