#44 SingleTon Pattern ?

1.It is essential when you need only one instance of a class.

2.The Class itself is responsible for maintaining only one instance of class(Breaks Single Responsibility).

3.They make the System Tightly Coupled.

Implementation:

1.Non-Thread Safe

2.Thread Safe-Single Lock

3.Thread Safe -Double Check Lock

4.Thread Safe-Lazy Loading.

Source Code:

Source Code of SingleTon

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s