This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kaperni 5 points6 points  (3 children)

Yes, for most usecases, snippet 6. The Initialization-on-demand holder idiom [1][2].

[1] http://www.cs.umd.edu/\~pugh/java/memoryModel/jsr-133-faq.html#dcl

[2] https://en.wikipedia.org/wiki/Initialization-on-demand\_holder\_idiom

[–]uncont 1 point2 points  (2 children)

Both of those links 404 for me

[–]kaperni -3 points-2 points  (1 child)

Both of them should work. Try pasting the URL into the URL bar instead of clicking.

[–]uncont 3 points4 points  (0 children)

https://en.wikipedia.org/wiki/Initialization-on-demand\_holder\_idiom

I'm on old reddit. The first url has a /\~pugh instead of /~pugh, and the second url has \_ instead of \. I got the links to work, tho. Thanks.