[concurrency-interest] Initializing a map inside a constructor
Howard Lewis Ship
hlship at gmail.com
Mon Mar 5 12:23:00 EST 2007
I'm seeing some very strange effects in my code under load. I've been
reviewing Brian Goetz's concurrency book, but I have a scenario I
frequently use that I have come to suspect:
I often have classes with a final field of type Map.
I initialize the Map, loading values inside the constructor. I never
change the contents
of the Map outside of the constructor.
I don't use a guard (i.e. synchronized) to access the map from other code.
Is this thread safe, or do I need to synchronize the methods (or wrap
the map in a synchronzing wrapper)?
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind
Professional Tapestry training, mentoring, support
and project work. http://howardlewisship.com
More information about the Concurrency-interest