Should I synchronize a static volatile variable?
问题 There are a few questions on this subject, but most skirt around this issue because it's not the intent of the question. If I have a static volatile in my class: private static volatile MyObj obj = null; and in a method below I do: public MyObj getMyObj() { if (obj == null) { obj = new MyObj();// costly initialisation } return obj; } will I need to synchronize to ensure only one thread writes to the field, or will any writes be immediately visible to other threads evaluating the obj == null