Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Originally posted by Basudev Agrawal:
Can this unsynchronized access somehow be the cause? Hope my explanation makes some sesce.
Originally posted by Annekee Dufour:
I also intend to use an unsynchronized hashmap. Since I expect a lot of gets (> 1000 a day) and iterates, and very little puts (12-15 a day), I don't want to synchronize every get and iterate action. Therefore, if I do a put, I start by cloning the original map, put something in the new map, and then assign the newmap to my original map variable. Is this a safe alternative to synchronizing?
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Originally posted by Annekee Dufour:
I also intend to use an unsynchronized hashmap. Since I expect a lot of gets (> 1000 a day) and iterates, and very little puts (12-15 a day),
Originally posted by Warren Dew:
Synchronizing the put() is not enough. If you only do that, a get() that occurs while the put() is in progress may get corrupted data.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Warren Dew:
Or you could just use Collections.synchronizedMap(new HashMap()) when getting the HashMap.
Originally posted by Henry Wong:
While I think this effort to remove synchronization is worthwhile, there also have to be a balance. The synchronization time for contended locks is improving with each release of Java.
Originally posted by Annekee Dufour:
I also intend to use an unsynchronized hashmap. Since I expect a lot of gets (> 1000 a day) and iterates, and very little puts (12-15 a day), I don't want to synchronize every get and iterate action. Therefore, if I do a put, I start by cloning the original map, put something in the new map, and then assign the newmap to my original map variable. Is this a safe alternative to synchronizing?
Originally posted by David Harkness:
If instead you only serialize writes -- the place where data structure corruption can certainly occur in the case of multiple writers -- you are minimizing contention.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ilja Preuss:
You also need to make sure that noone reads while a (non-atomic) write is in progress
after a write, all reading threads need to synchronize, else they might see inconsistent data because of not fully uptodate local caches.
Originally posted by David Harkness:
I remember reading an article by Doug Lea discussing various ways around this: using transient
synchronizing twice
Do you have an recent references on precisely how this should be done?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ilja Preuss:
I guess you mean volatile?
Me: synchronizing twice
IP: How would that work?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Henry Wong:
In fact, if you are changing an element with another element, you should also just grab the read lock; even though you are changing values, you are not changing the structure of the container, so it's thread safe.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ilja Preuss:
Unless the map has to resize, I assume?
Originally posted by David Harkness:
Why would the Map be resized when replacing the value for a pre-existing key?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Don't get me started about those stupid light bulbs. |