Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2008

Tip: Looking for answers? Try searching our database.

CopyOnWriteHashMap

Thread view: 
Philipp - 14 Jan 2008 17:20 GMT
Hello
I'am looking for a 1.3 JRE compatible CopyOnWriteHashMap.

I have seen that based on Doug Lea's work, the CopyOnWriteArrayList has
made it in the 1.5 API, but I would need the same for a Map.

Ie. a Map where insertions are rare, but iterations frequent. A Map
where synchronization is not necessary, because the whole data is copied
at a write event and thus Iterators may never get invalidated by another
thread.

Can anybody suggest an free&open source licensed file for this which I
could use in my project?

Thanks a lot.
Phil
Mark Space - 14 Jan 2008 18:00 GMT
> Hello
> I'am looking for a 1.3 JRE compatible CopyOnWriteHashMap.

Just curious: what the heck are you doing that's required to use a JRE
that's already been past end-of-line for some time now?

Sorry I can't help you with the library you need...
Philipp - 15 Jan 2008 08:21 GMT
> Hello
> I'am looking for a 1.3 JRE compatible CopyOnWriteHashMap.

To put it in another way, I want to use an OSGi service which is stored
in a map as explained in the felix turorial at
http://felix.apache.org/site/apache-felix-tutorial-example-6.html
There, the map is called "m_refToObjMap". Objects are added to it in a
synchronized way and iteration over it are done in a synchronized way as
well.
I want to avoid the overhead of synchronizing the iterations. I am
willing to pay for a higher cost at insertion (as for example copying
the data in the Map) for an unsynchronized (thus faster) iteration over
the map because I expect only one or two insertions, but millions of
iterations.

My question now boils down to the following: How can I do this in thread
safe manner. (one solution would be to use a CopyOnWriteHashMap which I
was asking for in the first place, but which I could not find).

Thanks for any replies
Phil
Gerhard Aschauer - 16 Jan 2008 09:04 GMT
>> Hello
>> I'am looking for a 1.3 JRE compatible CopyOnWriteHashMap.
[quoted text clipped - 17 lines]
> Thanks for any replies
> Phil

see:
http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/ConcurrentH
ashMap.html

Lew - 16 Jan 2008 14:28 GMT
> see:
> http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/ConcurrentH
ashMap.html
 

Is this a better choice than
<http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentHashMap.html>
?

If so, why?

Signature

Lew
This post contains two requests for information.

Philipp - 17 Jan 2008 09:26 GMT
>> see:
>> http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/ConcurrentH
ashMap.html
 
[quoted text clipped - 5 lines]
>
> If so, why?

Thanks to both of you. That is in fact what I'm looking for...
especially the backport to older JVMs at
http://backport-jsr166.sourceforge.net/index.php

Regards
Phil
Lew - 17 Jan 2008 14:26 GMT
>>> see:
>>> http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/ConcurrentH
ashMap.html
 
[quoted text clipped - 9 lines]
> especially the backport to older JVMs at
> http://backport-jsr166.sourceforge.net/index.php

Based on the Javadocs and unless Gerhard answers my questions, I'm concluding
that one should use the standard API class and not the custom New York EDU
version.

The documentation of the EDU version indicates that it's a pre-Java 5
implementation and doesn't understand the current memory model.  They also
talk about it as a replacement for Hashtable of all things, and the
documentation says nothing about generics.

I don't know why anyone would recommend this EDU version over the Java version.

Signature

Lew

Gerhard Aschauer - 18 Jan 2008 12:46 GMT
>>>> see:
>>>> http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/ConcurrentH
ashMap.html
 
[quoted text clipped - 21 lines]
> I don't know why anyone would recommend this EDU version over the Java
> version.

Lew,
because the Op said that he must be using V1.3.

Regards,
Gerhard
Lew - 18 Jan 2008 14:10 GMT
>>>>> see:
>>>>> http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/ConcurrentH
ashMap.html
 
[quoted text clipped - 24 lines]
> Lew,
> because the Op said that he must be using V1.3.

Yes, I got that belatedly.  Sorry for the opacity.

Signature

Lew

Lew - 17 Jan 2008 14:29 GMT
> Thanks to both of you. That is in fact what I'm looking for...
> especially the backport to older JVMs at
> http://backport-jsr166.sourceforge.net/index.php

How old must your JVM be?  The newest JVM not to support it is JVM 1.4, and
that's already in its End-of-Life process and will be retired outright in just
a few months.  Java 5 enters End-of-Life this summer if Sun follows its stated
policies and is on time with Java 7.

Anything older than 1.4 is already dead from Sun.

Signature

Lew
This post contains one request for information.

Philipp - 17 Jan 2008 17:09 GMT
>> Thanks to both of you. That is in fact what I'm looking for...
>> especially the backport to older JVMs at
>> http://backport-jsr166.sourceforge.net/index.php
>
> How old must your JVM be?  

I wonder how many times I will have to answer this question in this
forum (note that in the original post, I specified that I am looking vor
v.1.3 compatible code).
I am really very sorry, but I am unable to chose the JVM my client is
working with. He obviously has his own reason why to use an 1.3, I can't
change that. (I tried!)

Thanks again for the links which brought me to a solution.
Phil


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.