| «« 0.2.0 Update | Selecting with SWT Table and JFace TableViewer »» |
|
About
I'm Ryan Lowe, a Software Engineering graduate living in Ottawa, Canada. I like agile software development and Ruby on Rails.
I write this blog in Canadian English and don't use a spell checker. Typos happen.
Projects
» Full-time Ruby on Rails freelancer
» Full-time with Rails since May 2005 » Former committer for RadRails (now Aptana) » I also have a few Rails side-projects in development: 1. wheretogoinTO.com Toronto nightlife 2. Hey Heads Up! TODO list and sharing 3. Layered Genealogy family history research 4. foos for foosball scoring 5. fanconcert for music fans (on hold) Hiring Rails developers? I can telecommute by the hour from Ottawa, Canada »» Email: rails AT ryanlowe DOT ca
BulletBlog
Now hosted on Hey! Heads Up -- check it out!
Syndication
Pings
Recent
Derek Lowe's (Ryan's older brother) words at Ryan's funeral
blog@ryanlowe.ca no more Forging Email Headers: Good, Bad or Ugly? Sarcastic Dictionary (Part 1 of Many) Tags Hierarchies Twisting Rails is Risky Business Risky Business? My Take on Early Alphas Whoa, it's August 2007 Closing Comments A Postscript to "Growth at the grassroots" »» All Blog Posts
Linkage
del.icio.us/ryanlowe
technorati/ryanlowe.ca/blog Aurora Roy Jim Andrew Trasker Travis Kibbee Karen Dr. Unk Ayana Van Bloggers Joel Spolsky Robert Scoble Tim Bray Dave Winer Raymond Chen James Robertson Ruby/Rails Bloggers rubyonrails.org weblog David Heinemeier Hansson Dave Thomas James Duncan Davidson Mike Clark Jamis Buck Signal vs. Noise Tobias Luetke Amy Hoy: (24)slash7 Jeremy Voorhis Eclipse Bloggers Planet Eclipse EclipseZone Luis de la Rosa Eclipse Foundation Kim Horne Billy Biggs Ian Skerrett Mike Milinkovich Bjorn Freeman-Benson Denis Roy
Archives
|
Is a Hashtable of <String, Vector> Threadsafe?
I have a Java question but here's some background first. A Vector and an ArrayList both implement the List interface except a Vector is threadsafe because it has synchronized methods. Likewise, a Hashtable is a threadsafe implementation of the Map interface and HashMap is its thread unsafe compadre. ArrayList and HashMap exist because synchronized methods are expensive. So if you just need a Map and you're not going to use more than (the) one (main) thread then you can get a performance boost from HashMap. So here's the question: If I have a Hashtable where the keys are Strings and the values are Vectors of immuatable objects, is that threadsafe? I'm guessing probably not because all of the methods that manipulate this structure extract a Vector from the Hashtable, add or remove objects and then replace the Vector in the HashTable where it was. It looks like I'm going to have to make all of the mutator methods synchronized and take the performance hit. Speaking of threads, I'm probably going to pick up Taming Java Threads by Allen Holub soon. Has anyone used this book? Posted at February 11, 2004 at 09:24 PM ESTLast updated February 11, 2004 at 09:24 PM EST Comments
You will have to use synchronized methods if you want to do this. Ahh, good point. If I synchronize from the outside I can use HashMap and ArrayList on the inside. No sense doubling up the synchronized methods. Excellent. » Posted by: Ryan at February 11, 2004 11:16 PM |