HashMap thread safe for multi-thread read-only operations?
807588Feb 10 2009 — edited Feb 10 2009If I have a HashMap (initialized and loaded) via static initialization of the class and I never write to it or modify it again, it is thread-safe for multiple read-only threads? In other words, I don't need to use synchronization or a synchronized map, do I?
I believe I should be OK since the JVM handles the static initialization at class loading time, which is guaranteed to only happen once, so the mapping should be created in a thread-safe manner. From then on, if I only read from it I should be OK, right?
Thanks!!