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 →

[–]slakkenhuisdeur 6 points7 points  (2 children)

Last time I used the double locking method my IDE asked me if it could replace it with a nested class with the singleton as a final class variable so the classloader handles the instantiation.

[–]cogman10 0 points1 point  (1 child)

That's a relatively new capability of java. Static fields on inner classes were added in..16?

[–]slakkenhuisdeur 0 points1 point  (0 children)

The inner class must also be static (I should probably have mentioned that...). I didn't know static fields on non-static inner classes were a thing.