The moral of the story is that just because a class is fully synchronized, doesn’t mean it’s thread-safe. You still have to be on the look for those sequence of method calls that have to occur atomically, because method level synchronization won’t help in this regard. In other words, watch what you’re doing. Sometimes it’s not so obvious when exactly we’re supposed to synchronize our use of Collections. Ever encountered a ConcurrentModificationException before? I bet it’s probably because your code looks something like thisRead the complete post: http://rayfd.wordpress.com/2007/11/11/when-a-synchronized-class-isnt-threadsafe/
Blogs: When a synchronized Java class isn’t thread-safe
Just because you're using the synchronized keyword in your class, doesn't necessarily means its thread safe. This blog entry takes you through the process, so you can ensure thread safety in your classes.
- Posted by: Daniel Rubio
- Posted on: November 23 2007 19:35 EST
What's new in this blog ?