"Haseltine, Celeste" wrote: > > Pete, > > There are a few objects in Java that are synchronized, such as the Vector > object, but for the most part, synchronization is left up to the individual > developer. My understanding of why this was done was for performance > reasons (though someone from Sun would be more qualified to expand upon the > reasons for this then I). > > ... > > From a performance standpoint, it is much better to consider synchronizing > only the necessary methods in a class or segment of code, vs. synchronizing > the entire class object. By synchronizing the entire class or object, such > as a Hashtable, you decrease the performance of your application (only one > thread can run at a time), and if your not careful, you can sometimes run > the risk of threadlock. >
java.util.Hashtable is also synchronized. So if you need synchronized access, you can just use that class. If you want to roll your own locking better to look at the Collections classes that are by default unsynchronized, leaving the decision up to you (I think it is easy to get synchronized copies too). - Chris Hamlin ______________________________________________________________________ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm Archives: http://www.mail-archive.com/[email protected]/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
