3 ms·
But that unique instance is presumably referenced by other objects which may want to use it as part of their own shut down logic, at which point it might no lon
by pfedor 14y ago
But that unique instance is presumably referenced by other objects which may want to use it as part of their own shut down logic, at which point it might no longer exist. (And things get only worse in the presence of threads.)
- deleted 14y ago[deleted]
- pmelendez 14y agoSorry I read it again (the first time I was reading it on my phone) and I thought we were discussing about Meyers singleton: Singleton & theSingleton() { static Singleton instance; return instance; } Which in the proper context is perfectly fine. This is wrong: class myclass { // can have state // ... public static myclass m = new myclass(); // globally accessible static instance, which can have state } and the first link itself explain why.