Here, only differences are discussed, and usage is not discussed.
I am more concerned about the time, use, and use.
|
Static) |
Singleton) |
Level: |
Class Level |
Object level |
Features: |
One copy
|
One copy Keep a global object instance |
Memory storage: |
Category |
Category One copy |
Restrictions: |
Only static attributes and methods can be maintained |
Unlimited |
Restrictions: |
It cannot be inherited or overloaded and cannot implement interfaces. |
Unlimited |
Initialization: |
Delayed Initialization |
Delayed Initialization |
Internal implementation: |
Static |
The internal implementation of the Singleton is also static. |
Multi-thread concurrent access: |
Equivalent |
Equivalent |
Performance: |
Equivalent |
Equivalent |
Comparison, comparison, still do not see the big difference... Nothing unexpected ..
Discuss the singleton mode and static class again: http://raychase.iteye.com/blog/1471015