Singleton pattern with combination of lazy loading and thread safety

Your second code snippet is, in my opinion, the best way of thread-safe lazily initializing a singleton. It actually has a pattern name

Initialization-on-demand holder idiom

I would suggest you use it.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)