4 ms·
I thought the best way to use singletons in Java these days was via enums, e.g. as http://codereview.stackexchange.com/a/27298 http://codereview.stackexchange.c
by wink 12y ago
I thought the best way to use singletons in Java these days was via enums, e.g. as http://codereview.stackexchange.com/a/27298 http://codereview.stackexchange.com/a/27298 describes it - can anyone elaborate on why that's not even mentioned in the article?
- jrochkind1 12y agoI _think_ that implementation is non-lazy? The OP is not interested in that case. > 3. It is lazy. One can argue about this, but non-lazy factories are not interesting for our discussion. Singleton initialization should happen with the first request for a Singleton, not when Singleton class is initialized. If no one wants a Singleton instance, we should not instantiate it.