Quantcast
Browsing latest articles
Browse All 5 View Live

Answer by Volo for Lazy initialization without synchronization or volatile...

This statement sounds a little bit cryptic. However, I guess HLS refers to the case when you lazily initialize an instance field and don't care if several threads performs this initialization more than...

View Article


Answer by artbristol for Lazy initialization without synchronization or...

I think the statement is untrue. Another thread can see a partially initialized object, so the reference can be visible to another thread even though the constructor hasn't finished running. This is...

View Article


Answer by Peter Lawrey for Lazy initialization without synchronization or...

This works fine under some conditions.its okay to try and set the field more than once.its okay if individual threads see different values.Often when you create an object which is not changed e.g....

View Article

Answer by Gray for Lazy initialization without synchronization or volatile...

Hrm. As I read this it is technically incorrect but okay in practice with some caveats. Only final fields can safely be initialized once and accessed in multiple threads without synchronization.Lazy...

View Article

Lazy initialization without synchronization or volatile keyword

The other day Howard Lewis Ship posted a blog entry called "Things I Learned at Hacker Bed and Breakfast", one of the bullet points is:A Java instance field that is assigned exactly once via lazy...

View Article

Browsing latest articles
Browse All 5 View Live